我有一个字符串,并且我将值赋为
i have one string, and i assign the value like,
string str="admin" + @"\" + "user";"str"值的输出为
管理员 \\ 用户"
.但是我需要将"str"值设为
. But i need "str" value as
管理员 \ 用户"
.这意味着我需要在字符串值内使用单个"\" 符号,而不是"\\" .我怎么能得到这个?
. That means i need single "\" symbol instead of "\\" within the string values. How can i get this?
推荐答案
"str"值的输出为"admin \\ user"
The output of the "str" value comes as "admin\\user"
不,实际上不是.字符串本身只有一个反斜杠.
No, it really doesn't. The string itself will just have a single backslash.
如果您在调试器中查看,则会看到转义符,但这并不意味着它是字符串的一部分.这只是调试器的表示形式.将其打印到控制台,或登录等以查看实际值.
If you look at it in the debugger you will see the escaping, but that doesn't mean it's part of the string. It's just the debugger representation. Print it to the console, or log etc to see the real value.
更多推荐
带"\"的转义序列象征
发布评论