What is the difference between a regular string and a verbatim string?

Xaisoft picture Xaisoft · Jul 22, 2010 · Viewed 81.2k times · Source

I have a trial version of Resharper and it always suggests that I switch regular strings to verbatim strings. What is the difference?

Answer

alc6379 picture alc6379 · Jul 22, 2010

A verbatim string is one that does not need to be escaped, like a filename:

string myFileName = "C:\\myfolder\\myfile.txt";

would be

string myFileName = @"C:\myfolder\myfile.txt";

The @ symbol means to read that string literally, and don't interpret control characters otherwise.