If we try to run this code:
int d = 10/0;
We get a compiler error. So we cannot divide by zero.
Now consider this code:
<
the c# compiler is only doing constants value arithmetic check, and there for can tell that you can't do 10/0
. it's a lot more then you think for a compiler to do that.
even more then that: the c# compiler allows:
1.0 / 0 // Infinity
because:
Floating-point arithmetic overflow or division by zero never throws an exception, because floating-point types are based on IEEE 754 and so have provisions for representing infinity and NaN (Not a Number).