Why is a cast required for byte subtraction in C#?
This question already has an answer here:
Because subtraction is coercing up to an integer. As I recall, byte is an unsigned type in C#, so subtraction can take you out of the domain of bytes.
这是因为字节减法的结果不适合一个字节:
byte - byte = (0..255) - (0..255) = -255..255
字节上的算术结果默认为一个int值。
链接地址: http://www.djcxy.com/p/21106.html上一篇: 为什么从Int16变量Int32中减去Int16参数的结果?
下一篇: 为什么C#中的字节减法需要强制转换?