[英]ASP.NET / C# : variable with double quote
In ASP.NET & C#, I try to declare a variable with double quote in it, for eg. 在ASP.NET和C#中,我尝试声明一个带有双引号的变量,例如。
string str1 = @"""quote""";
The result I expect to get is "quote", but the result I get is "\\"quote\\"", can anybody help? 我希望得到的结果是“ quote”,但是我得到的结果是“ \\” quote \\””,有人可以帮忙吗?
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. 如果要查看正确的字符串(不带
\\
),请在QuickWatch弹出窗口中单击左侧的放大镜图标。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.