Infinity or Exception in C# when divide by 0?

Divide by zero is the System.DivideByZeroException, which is a class that handles errors generated from dividing a dividend with zero.

Let us see an example.

Example

result = num1 / num2;

Above, if num2 is set to 0, then the DivideByZeroException is caught since we have handled exception.

Updated on: 2026-03-11T23:26:52+05:30

2K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements