In C# can casting a Char to Int32 produce a negative value?

后端 未结 5 843
时光取名叫无心
时光取名叫无心 2021-01-18 11:03

Or is it always guaranteed to be positive for all possible Chars?

5条回答
  •  太阳男子
    2021-01-18 11:42

    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.

提交回复
热议问题