Given the following code:
string source = "Some Unicode String"; foreach( char value in source ) { int y = (int)value; }
Is it possible that casting from char to int might fail (and under what circumstances)?
Converting from charto intwill not be performed with any value char.
char
int
From . Link NET 4.0
.NET Framework Char Unicode . Unicode 21- , , UTF-16, , 16- . 16- hexadecimal 0x0000 0xFFFF Char. Char - 16- () .
, , . A char 0x0 0xFFFF (65535), int -2,147,483,648 2,147,483,647, char int.