In ASP.NET & C#, I try to declare a variable with double quote in it, for eg.
string str1 = @"""quote""";
The result I expect to get is "quote", but the result I get is "\\"quote\\"", can anybody help?
What you've done is correct. I believe you are inspecting the string value through QuickWatch/Watch window. If so, you will see escape character \\
before every double quote inside the string. Just try this and see you actual value.
Console.WriteLine(str1);
If you want to see a proper string (without \\
), click on the magnify glass icon on the left in QuickWatch pop-up.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.