News for hackers. Stuff that matters.
Re:C#: No, you don’t get to use the “as” operator any more by lucisferre on Friday April 29, 2011 @04:56PM (#2498962)
Yeah I no argument that it's good to know what your code does but what you choose to do is context specific, why would throwing InvalidCastException be better than NullRef, neither tell me why the failure happened.

On a somewhat unrelated note why is this trivial C# 101 lesson on the bloody front-page. I've got to imagine maybe 1 out of 10 readers care and far fewer didn't already know this.

Re:C#: No, you don’t get to use the “as” operator any more by jbrechtel on Friday April 29, 2011 @06:40PM (#2499275)
InvalidCastException include the class name, doesn't it? That makes it order of magnitude easier to track down where it came from. The NullRef just tells you that it MAY have been that the 'as' failed, or it could have been a bona-fide NullRef.