声明包含一个单引号/撇号char值的最清晰的方式 [英] Clearest way to declare a char value containing a single quote/apostrophe
本文介绍了声明包含一个单引号/撇号char值的最清晰的方式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
要声明一个char值在C#中,我们只是围绕着字符单引号:'X'
To declare a char value in C# we just surround the character with single quotes: 'x'
.
但什么是最清晰的方式来声明的是的一个单引号/撇号?
But what is the "clearest" way to declare a char value that is a single quote/apostrophe?
我已经结束了使用'[0]
,虽然我曾预计''''
工作(其依据是,
可用于分隔字符串中的一个引号字符。
I've ended up using "'"[0]
, though I had expected ''''
to work (on the basis that ""
can be used to delimit a quote character within a string.
是否有一个合理的,更简洁的选择吗?
Is there a sensible, more succinct option?
推荐答案
您可以使用反斜线报价:'\''
You can escape the quote with a backslash: '\''
这篇关于声明包含一个单引号/撇号char值的最清晰的方式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文