String literal still ending up with double slashes? [duplicate]

人走茶凉 提交于 2019-12-04 06:15:18

问题


I have a small piece of code:

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;
}

If I debug and stop just after path is set it looks like “C:\\\Users\\\Public\\\filename.txt”.

Can anyone tell me why it has the double slashes? Is the '@' sign actually messing it up in this case?

How I may get it as “C:\Users\Public\filename.txt”


回答1:


The double slashes are only there for the debugger, not your actual application. Your code is fine.



来源:https://stackoverflow.com/questions/14386076/string-literal-still-ending-up-with-double-slashes

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!