I really don't like the C# "as" operator. I have to admit that I made it a point not to use this solely because it made me have a brief moment of "VB.NET flashback". I personally have a strong dislike for VB.NET syntax but that's just my preference. Because of my VB.NET bias I did not look at the C# language spec to see if "as" functioned differently from
string foo = (string)myType;
As it turns out I tracked down a difficult bug in our system that was due to the fact that using "as" returns a null reference rather than throwing a class cast exception like c-style casting does. Granted part of the problem was people swallowing exceptions in code, but I'm wondering: under what circumstances would one want the behavior that "as" provides?
Remember Me
a@href@title, strike
Powered by: newtelligence dasBlog 2.0.7226.0
Disclaimer The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.
© Copyright 2008, Damon Payne
E-mail