See Also: DivideByZeroException Members
The following CIL instructions throw DivideByZeroException:
The following example demonstrates an error that causes a DivideByZeroException exception.
C# Example
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
Example
Error: System.DivideByZeroException: Attempted to divide by zero. at DivideZeroTest.Main()