public class ArithmeticException : SystemException
Object
Exception
SystemException
ArithmeticException
mscorlib
BCL
Represents an error caused by an arithmetic operation.
[Note: The Base Class Library includes two types derived from ArithmeticException:When appropriate, use these types instead of ArithmeticException.
]
[Note: The following IL instructions throw ArithmeticException:
]
- ckfinite
- div
The following example demonstrates an error that causes the system to throw a ArithmeticException error.
using System; class testNan { public static void Main() { double myNan = Double.NaN; try { Math.Sign(myNan); } catch (ArithmeticException e) { Console.WriteLine("Error: {0}",e); } } }The output is
Error: System.ArithmeticException: Function does not accept floating point Not-a-Number values.
at System.Math.Sign(Double value)
at testNan.Main()
System Namespace
ArithmeticException Constructors
ArithmeticException() Constructor
ArithmeticException(System.String) Constructor
ArithmeticException(System.String, System.Exception) Constructor
public ArithmeticException();
Constructs and initializes a new instance of the ArithmeticException class.
This constructor initializes the System.ArithmeticException.Message property of the new instance to a system-supplied message that describes the error, such as "The arithmetic operation is not allowed." This message takes into account the current system culture.The System.ArithmeticException.InnerException property is initialized to
null
.
System.ArithmeticException Class, System Namespace
public ArithmeticException(string message);
Constructs and initializes a new instance of the ArithmeticException class.
- message
- A String that describes the error. The content of message is intended to be understood by humans. The caller of this constructor is required to ensure that this string has been localized for the current system culture.
This constructor initializes the System.ArithmeticException.Message property of the new instance using message. If message isnull
, the System.ArithmeticException.Message property is initialized to the system-supplied message provided by the constructor that takes no arguments. The System.ArithmeticException.InnerException property is initialized tonull
.
System.ArithmeticException Class, System Namespace
public ArithmeticException(string message, Exception innerException);
Constructs and initializes a new instance of the ArithmeticException class.
- message
- A String that describes the error. The content of message is intended to be understood by humans. The caller of this constructor is required to ensure that this string has been localized for the current system culture.
- innerException
- An instance of Exception that is the cause of the current exception. If innerException is non-null, then the current exception was raised in a catch block handling innerException .
This constructor initializes the System.ArithmeticException.Message property of the new instance using message, and the System.Exception.InnerException property using innerException. If message isnull
, the System.ArithmeticException.Message property is initialized to the system-supplied message provided by the constructor that takes no arguments.[Note: For information on inner exceptions, see System.Exception.InnerException.]
System.ArithmeticException Class, System Namespace