是否有可能将或打印\在控制台中写入或打印
我有一个问题。我可以在vscode中写入\吗?我试图将ASCII角色打印到我正在从事的小项目的控制台中,因为我正在尝试学习C# 我累了所有的东西,我唯一得到的就是这样的消息:常数包含newline字符。 我知道这是什么意思,因为\ n构成了一条新线路。我试图搜索互联网,但没有看到与我要问的有关的任何内容。有帮助吗? 谢谢您看到这个问题 - 亨利
I have a question. Can I write \ into a conosle in vscode? I tried to print an ascii character into the console for my little project that I am working on, because I am trying to learn c#
I have tired everything and the only thing I get is this message: the constant contains the newline character.
I know what it means because \n make a new line. I tried to search the internet and I didnt see anything related to what I am asking. Any help?
Thank you for seeing this question
-Henry
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Backslash(
\
)在C#中用作逃生字符。您可以找到有关逃生序列的文档在这里当您仅键入一个后斜线时,编译器将将此字符(和下一个)解释为逃生序列。
就像Progman建议的那样,您可以键入“
\\
”以在控制台中显示后斜线。The backslash (
\
) is used as an escape character in C#. You can find the documentation about escape sequences hereWhen you type just one backslash, the compiler will therefore interpret this character (and the next one) as an escape sequence.
Like Progman suggested, you can type "
\\
" to display a backslash in the Console.是,您可以在控制台上打印
\
。\
实际上是一个逃生序列,因此是混乱。检查一下逃生序列:在这里
在C#中的Console上打印“ \” -
Yes, you can print
\
on console.\
is actually an escape sequence, hence the confusion.Check this for escape sequences : here
To print "\" on the console in C# -