When C# first came out I spent an absorbent amount of time checking the language reference and ensuring that my C++ and VB6 know how was appropriately ported to this new language. So I must admit to being a little annoyed that I just found out about the is operator today.

The is operator is used to check whether the run-time type of an object is compatible with a given type. The following example highlights it practical uses.

MyClass mc;
if(mc is MyClass){
    '... do stuff
}

How useful is that? Why did I think reflection was the best way to solve this problem? When I was in Portland a couple of years ago I distinctly remember someone asking how to solve a problem of this ilk. I proudly explained the beauty of reflection and sent a long winded sample ... I was so wrong ;(

"Look back, and smile on perils past." - Walter Scott

Technorati tags: ,