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

前端 未结 6 1121
轻奢々
轻奢々 2020-11-22 10:11

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

6条回答
  •  误落风尘
    2020-11-22 10:39

    You can have multiline string too using verbatim strings:

    Console.WriteLine(@"This
        is
        a
        Test
        for stackoverflow");
    

    without @ you got an error.

    In VB14 there is a new feature called Multiline Strings, it's like verbatim strings in C#.

    Multiline Strings

    Pro tip: VB string literals are now exactly like C# verbatim strings.

提交回复
热议问题