Click here to Skip to main content
Click here to Skip to main content
Alternative Tip

Tagged as

Go to top

Parse out controls from your html page.

, 6 Nov 2011
Rate this:
Please Sign up or sign in to vote.
Tip - Never use type equality because that does not support derived classes:if (item.GetType() == typeof(Image)) //this is bad, mkay.Instead use the following which does support derived classes:if (item is Image)The Microsoft prefered pattern (when you actually need the cast object)...

Tip - Never use type equality because that does not support derived classes:

if (item.GetType() == typeof(Image)) //this is bad, mkay.

Instead use the following which does support derived classes:

if (item is Image)

The Microsoft prefered pattern (when you actually need the cast object) is:

var itemAsType = item as Image;
if (itemAsType != null)

That way, you will only have to typecast once.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Kabwla.Phone
Software Developer (Senior)
Netherlands Netherlands
Doing that 'computer thing' ever since the C64.
 
Sometimes I feel that being a programmer is much like being a doctor: You just have to know everything and if you don't, something dies.
 
Either being an appliction or a patient.
Oddly enough, more people care about the death of their application, than the massacre op people...

Comments and Discussions

 
-- There are no messages in this forum --
| Advertise | Privacy | Mobile
Web04 | 2.8.140916.1 | Last Updated 6 Nov 2011
Article Copyright 2011 by Kabwla.Phone
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid