Mono Class Library: System NamespaceSystem.OverflowException Class |
See Also: OverflowException Members
System.Object
System.Exception
System.SystemException
System.ArithmeticException
System.OverflowException
|
All public static members of this type are safe for multithreaded operations. No instance members are guaranteed to be thread safe.
In languages that detect overflow, this is the exception that gets thrown. For example, in C#, the checked keyword is used to detect overflow conditions. A OverflowException exception occurs only in a checked context.
Note:[Edit]The following CIL instructions throw OverflowException :
- add.ovf.<signed>
- conv.ovf.<to type>
- conv.ovf.<to type>.un
- mul.ovf.<type>
- sub.ovf.<type>
- newarr
The following example demonstrates an error that causes a OverflowException exception.
C# Example using System; public class OverflowExample { public static void Main() { int i = 400; byte b = 0; try { checked { b = (byte)( i ); } } catch ( OverflowException e ) { Console.WriteLine( "Error caught: {0}", e ); } } }The output is
Example Error caught: System.OverflowException: Arithmetic operation resulted in an overflow. at OverflowExample.Main()
Namespace: System
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0