Search code examples
c#resharperstring-literalsrawstringverbatim-string

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


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


Solution

  • 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.