【问题标题】:additing the same numbers in int and byte, why results are different? c#在 int 和 byte 中添加相同的数字,为什么结果不同? C#
【发布时间】:2022-12-01 02:24:06
【问题描述】:
当它隐式转换为 int 时 - 结果很明显,但是当它添加字节时 - 它不同,为什么?
【问题讨论】:
标签:
c#
integer
byte
addition
operation
【解决方案1】:
您的代码刚刚溢出 byte — 它支持从 0 到 255 的值。您应该至少使用 short。