Throwing an exception if, for example, int a = Integer.MIN_VALUE-1; [closed]
Want to improve this question? Add details and clarify the problem by editing this post.
开发者_如何学PythonClosed 8 years ago.
Improve this questionDo you know of any languages which would throw an Exception on Overflow or Underflow? Thanks
.Net framework has a dedicated exception for Overflow
OverflowException Class
In C# you can let underflow and overflow throw exceptions using the checked
keyword:
int a = checked(Integer.MIN_VALUE - 1);
精彩评论