... all I'm offering is the truth. Nothing more. RSS 2.0
# Tuesday, May 01, 2007

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: ,
Tuesday, May 01, 2007 6:42:51 PM (Eastern Daylight Time, UTC-04:00)  #    Comments [0] - Trackback
.NET | C#
Blogroll
Statistics
Total Posts: 335
This Year: 23
This Month: 1
This Week: 1
Comments: 32
About the author/Disclaimer

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

© Copyright 2010
Mark Downie
Sign In
All Content © 2010, Mark Downie
DasBlog theme 'Business' created by Christoph De Baene (delarou)