可能重复:
C#中字符串前面的@是什么?
这是我长期以来质疑的事情,但从来没有费心去弄清楚.当我下载第三方库时,我经常在字符串@之前使用符号看到字符串赋值.
string myString = @"Some text";
Run Code Online (Sandbox Code Playgroud)
但是,如果我这样做,似乎绝对没有区别
string myString = "Some text";
Run Code Online (Sandbox Code Playgroud)
那是@做什么的?
它表示逐字字符串文字,并允许您不必转义某些字符:
string foo = @"c:\some\path\filename.exe";
Run Code Online (Sandbox Code Playgroud)
VS:
string foo = "c:\\some\\path\\filename.exe";
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
151 次 |
| 最近记录: |