Int vs Double and divide by zero exception [duplicate]
问题 This question already has answers here : Inconsistency in divide-by-zero behavior between different value types (5 answers) Closed 2 years ago . We get compile time error when integer is divided by zero whereas in case of double there is no compilation error but at run-time we get infinity/NaN as the result. Any idea why int & double have different behavior when it comes to divide by zero exception? void Main() { int number = 20; var result1 = number/0; // Divide by zero compile time