Casting in C# (Part II)

One caveat to remember while type checking in C#, suppose you have a ‘Derived’ class that derives from a ‘Base’ class, then there is a difference between the following,
base1.JPG
The ‘GetType()’ check fails and the ‘is’ check is possibly what you want.

Advertisements

About soumya chattopadhyay
I live and work in Seattle, WA. I work with Microsoft technologies, and I'm especially interested in C#.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: