c# - Can't understand result of `a + c` when both are char -
I have programmed to add a pound symbol to the input value of the user through the command line.
I can not understand the output of the console application code:
Fixed zero main (string [] args) {char a = '\ u00A3'; // pound symbol Console.WriteLine ("Enter value"); Char c = Convert. Tochar (console. Read ()); For example // user type C console WrightLine (a + c); // this??? }
Print Console.WriteLine (a + c)
?
When you add two codes, you actually enter two integers ( int
).
Therefore, '\ u00A3' + 'c'
is (int) '\ u00A3' + (int) 'c'
. ( c
here as a sample, it depends on your input)
\ u00A3
( '£'
) = 163, c
= 99. Then the end result = 262
.
As a result int
is ToString ()
printed on the ad and console.
Comments
Post a Comment