BCL mscorlib [00 00 00 00 00 00 00 00 04 00 00 00 00 00 00 00 ] 1.0.5000.0 2.0.0.0 4.0.0.0 All public static members of this type are safe for multithreaded operations. No instance members are guaranteed to be thread safe. System.ArithmeticException System.Runtime.InteropServices.ComVisible(true)

The following example demonstrates an error that causes a exception.

`using System; public class DivideZeroTest { public static void Main() { int x = 0; try { int y = 100/x; } catch (DivideByZeroException e) { Console.WriteLine("Error: {0}",e); } } }`

The output is

`Error: System.DivideByZeroException: Attempted to divide by zero. at DivideZeroTest.Main()`

Trying to divide an integer or decimal number by zero throws a exception. Dividing a floating-point value by zero doesn't throw an exception; it results in positive infinity, negative infinity, or not a number (NaN), according to the rules of IEEE 754 arithmetic. Because the following example uses floating-point division rather than integer division, the operation does not throw a exception.

code reference: System.DivideByZeroException.Class#2

For more information, see and .

The following Microsoft intermediate language (MSIL) instructions throw :

div

div.un

rem

rem.un

uses the HRESULT COR_E_DIVIDEBYZERO, which has the value 0x80020012.

For a list of initial property values for an instance of , see the constructors.

The exception that is thrown when there is an attempt to divide an integral or decimal value by zero.

- Constructor
  1.0.5000.0
  2.0.0.0
  4.0.0.0

  This constructor initializes the property of the new instance to a system-supplied message that describes the error, such as "Attempted to divide by zero." This message takes into account the current system culture.

  The following table shows the initial property values for an instance of .

  Property

  Value

  A null reference (Nothing in Visual Basic).

  The localized error message string.

  Initializes a new instance of the class.

  0
- Constructor
  1.0.5000.0
  2.0.0.0
  4.0.0.0

  The content of 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.

  The following table shows the initial property values for an instance of .

  Property

  Value

  A null reference (Nothing in Visual Basic).

  The error message string.

  Initializes a new instance of the class with a specified error message.

  A that describes the error.
  0
- Constructor
  1.0.5000.0
  2.0.0.0
  4.0.0.0

  This constructor is called during deserialization to reconstitute the exception object transmitted over a stream.

  Initializes a new instance of the class with serialized data.

  The object that holds the serialized object data.
  The contextual information about the source or destination.
- Constructor
  1.0.5000.0
  2.0.0.0
  4.0.0.0

  An exception that is thrown as a direct result of a previous exception should include a reference to the previous exception in the property. The property returns the same value that is passed into the constructor, or null if the property does not supply the inner exception value to the constructor.

  The following table shows the initial property values for an instance of .

  Property Type

  Condition

  The inner exception reference.

  The error message string.

  Initializes a new instance of the class with a specified error message and a reference to the inner exception that is the cause of this exception.

  The error message that explains the reason for the exception.
  The exception that is the cause of the current exception. If the parameter is not null, the current exception is raised in a catch block that handles the inner exception.
  0
0