Converting bool expression to char in c#

前端 未结 3 2013
旧巷少年郎
旧巷少年郎 2021-02-07 01:00

I passed .NET quiz, when I met a question like below one.

Char ch = Convert.ToChar(\'a\' | \'e\' | \'c\' | \'a\');

In console we can see that o

3条回答
  •  被撕碎了的回忆
    2021-02-07 01:19

    "|" is the binary OR operator.

    'a' binary representation is 01100001
    'e' binary representation is 01100101
    'c' binary representation is 01100011
    

    The result of the OR is 01100111, whose char representation is g

提交回复
热议问题