字符串文字仍以双斜线结尾?

Zho*_*len 0 c# string string-literals

我有一小段代码:

public static void Write(string filename){
    string time = DateTime.Now.ToString("hh:mm tt");
    int date = int.Parse(DateTime.Now.ToString("yyyyMMdd"));
    string path = @"C:\Users\Public\" + filename;
}
Run Code Online (Sandbox Code Playgroud)

如果我调试并在路径设置后停止它看起来像 “C:\\\Users\\\Public\\\filename.txt”.

谁能告诉我为什么它有双斜线?'@'在这种情况下,标志是否真的搞乱了?

我怎么可能得到它 “C:\Users\Public\filename.txt”

key*_*rdP 8

双斜杠仅用于调试器,而不是您的实际应用程序.你的代码很好.

  • 调试器将文字显示为正确的C#:只是没有@.如图所示,它将正确地往返. (2认同)