Or is it always guaranteed to be positive for all possible Chars?
Each 16-bit value ranges from hexadecimal 0x0000 through 0xFFFF and is stored in a Char structure.
Char Structure - MSDN
See Microsoft's documentation
There you can see, that Char is a 16 bit value in the range of U+0000 to U+ffff. If you cast it to a Int32, there should be no negative value.
It's guaranteed to be non-negative.
char
is an unsigned 16-bit value.
From section 4.1.5 of the C# 4 spec:
The
char
type represents unsigned 16-bit integers with values between 0 and 65535. The set of possible values for thechar
type corresponds to the Unicode character set. Althoughchar
has the same representation asushort
, not all operations permitted on one type are permitted on the other.
Since the range of char is U+0000 to U+ffff, then a cast to an Int32
will always be positive.
char
can be inplicitly converted to ushort
and ushort
range is 0 to 65,535
so its always positive