Do you find code using 'as' operator without a null check buggy?
Not only do you trade a better telling InvalidCastException for a NullReferenceExeption, but using the as operator your code is saying you are not exactly sure what you are casting to.
Just wondering your thoughts and sure I am guilty of posting examples of using as operator with no null check.
The general rule I've always followed is to use 'as' when I want to know if the object is an instance of the type, and/or when I will use it as that afterwords, but is not an error if the object isn't an instance of the type.
I use a cast when the object must be of the type being cast to, or its an error.
I pretty much always do a null check after 'as', which is what you're supposed to do.
An InvalidCastException is not a hardware exception. A NullReferenceExeption is a hardware exception, and that seems to be why AutoCAD sometimes dies when they happen.