当我遇到如下问题时,我通过了 .NET 测验。
Char ch = Convert.ToChar('a' | 'e' | 'c' | 'a');
在控制台中,我们可以看到 ch
变量的输出是 g
。
有人能描述一下发生了什么吗? 谢谢!
最佳答案
“|”是二元或运算符。
'a' binary representation is 01100001
'e' binary representation is 01100101
'c' binary representation is 01100011
OR
的结果为01100111
,其字符表示为g
关于c# - 在 C# 中将 bool 表达式转换为 char,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38178498/