带"\"的转义序列象征 [英] Escape sequence with "\" symbol

查看:35
本文介绍了带"\"的转义序列象征的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个字符串,并且我将值赋为

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.

这篇关于带"\"的转义序列象征的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆