相关疑难解决方法(0)

在C#中处理整数溢出的最佳方法是什么?

处理整数溢出是一项常见任务,但在C#中处理它的最佳方法是什么?是否有一些语法糖比其他语言更简单?或者这真的是最好的方式吗?

int x = foo();
int test = x * common;
if(test / common != x)
    Console.WriteLine("oh noes!");
else
    Console.WriteLine("safe!");
Run Code Online (Sandbox Code Playgroud)

.net c# integer overflow

42
推荐指数
5
解决办法
3万
查看次数

标签 统计

.net ×1

c# ×1

integer ×1

overflow ×1