Arithmetic operation resulted in an overflow. (Adding integers)

前端 未结 8 1659
既然无缘
既然无缘 2020-12-20 11:16

I can\'t understand this error:

In this call to method SetVolume, Volume = 2055786000 and size = 93552000. Volume is an Integer pr

8条回答
  •  隐瞒了意图╮
    2020-12-20 11:46

    The maximum value of an integer (which is signed) is 2147483647. If that value overflows, an exception is thrown to prevent unexpected behavior of your program.

    If that exception wouldn't be thrown, you'd have a value of -2145629296 for your Volume, which is most probably not wanted.

    Solution: Use an Int64 for your volume. With a max value of 9223372036854775807, you're probably more on the safe side.

提交回复
热议问题