Joseph Cooney's Weblog
object value = 1 / 0.0;
Will it throw an exception at run-time? If not what value will value have after this line has run? Kudos to those who didn't need to check.
posted on Thursday, March 15, 2007 6:33 AM
Ooh that's interesting - how about -1 / 0.0 ? :-) Chris
My wife says it will so there! She also says it will give you a divide by zero error at run time. To add an opposing view, my cat thinks it wont compile.
If I remember my specs correctly, 'value' will have a boxed NaN value. I think I recall a PositiveInfinity and NegativeInfinity in Int32, but that's a longshot.
Dang, I hate these "interview" pop quizes. I'm gonna throw a guess and I say it will compile but will throw an exception at run time.
Forgot to add that if it's an unchecked statement (or unchecked project), an Exception will be thrown, although I'm not sure it would even compile...
It will not compile since value is a reserved word, right?
Powered by: Copyright © Joseph Cooney