处理整数溢出是一项常见任务,但在C#中处理它的最佳方法是什么?是否有一些语法糖比其他语言更简单?或者这真的是最好的方式吗?
int x = foo(); int test = x * common; if(test / common != x) Console.WriteLine("oh noes!"); else Console.WriteLine("safe!");
.net c# integer overflow
.net ×1
c# ×1
integer ×1
overflow ×1