In C# char
is a 16-bit numeric type, so +
means addition, not concatenation. Therefore, when you add a
and b
you get a+b
. Moreover, the result of this addition is an int
(see a quick demo).
If by "adding two characters" you mean "concatenation", converting them to a strings before applying operator +
would be one option. Another option would be using string.Format
, like this:
string res = string.Format("{0}{1}", charA, charB);
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…