【问题标题】: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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-11-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-02-17
      • 2012-08-12
      • 2017-08-25
      • 2019-09-25
      相关资源
      最近更新 更多