"在字符文字错误"字符太多; [英] "Too many characters in character literal error"
本文介绍了"在字符文字错误"字符太多;的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一段代码挣扎,得到的错误:
I'm struggling with a piece of code and getting the error:
在字符文字错误太多字符
Too many characters in character literal error
使用C#和switch语句通过字符串缓冲区迭代和阅读记号,但得到的错误在这行:
Using C# and switch statement to iterate through a string buffer and reading tokens, but getting the error in this line:
案'和;&放大器;':
case '&&':
情况下,'||':
情况下,'==':
我如何才能让 ==
和&放大器;&放大器;
为char
How can I keep the ==
and &&
as a char?
推荐答案
这是因为,在C#中,单引号()代表(或封装)单个字符,而双引号(
)用于字符的字符串。例如:
This is because, in C#, single quotes (''
) denote (or encapsulate) a single character, whereas double quotes (""
) are used for a string of characters. For example:
var myChar = '=';
var myString = "==";
这篇关于"在字符文字错误"字符太多;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文