问题
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