How to use “\” in a string without making it an escape sequence - C#?

后端 未结 6 2107
后悔当初
后悔当初 2020-12-14 23:35

I\'m sure this is something really basic that I don\'t know but how do I make it not recognize \"\\\" as an escape sequence inside a string

I\'m trying to type in a

6条回答
  •  北海茫月
    2020-12-15 00:20

    You can use Verbatim String Literals:

    //Initialize with a regular string literal.
    string oldPath = "c:\\Program Files\\Microsoft Visual Studio 8.0";
    
    // Initialize with a verbatim string literal.
    string newPath = @"c:\Program Files\Microsoft Visual Studio 9.0";
                     ↑
    

提交回复
热议问题