Divide by Zero Exception in C#: DivideByZeroException, Infinity and NaN (.NET 10)
Here’s the line that takes down a sales report: totalSales / orders on a region with zero orders. With int values it throws a divide by zero exception in C#; switch both to double and it quietly prints ∞ instead. Quick answer: integer and decimal division by zero throw DivideByZeroException, so check the divisor first. … Read more >>