65.9K
CodeProject is changing. Read more.
Home

Parse out controls from your html page.

starIconstarIconstarIconstarIconstarIcon

5.00/5 (1 vote)

Nov 1, 2011

CPOL
viewsIcon

4671

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.