为什么我没有得到整数 (uint) under/overflow 的异常?
Why don't I get an exception on integer (uint) under/overflow?
今天无意中发现了这个。这应该发生吗?这是我们都应该被警告的事情吗?
因为这是一个无符号整数,我不应该得到一个错误吗?
uint foo = 10;
foo = foo - 35;
Console.WriteLine(foo);
输出:4294967271
你有一个算术溢出只需启用 Build-Advanced-Check for arithmetic... 你会得到这个异常:
An unhandled exception of type 'System.OverflowException' occurred in
Additional information: Arithmetic operation resulted in an overflow.
今天无意中发现了这个。这应该发生吗?这是我们都应该被警告的事情吗?
因为这是一个无符号整数,我不应该得到一个错误吗?
uint foo = 10;
foo = foo - 35;
Console.WriteLine(foo);
输出:4294967271
你有一个算术溢出只需启用 Build-Advanced-Check for arithmetic... 你会得到这个异常:
An unhandled exception of type 'System.OverflowException' occurred in Additional information: Arithmetic operation resulted in an overflow.