Is Descendent

  • Thread starter Thread starter Juan Gabriel Del Cid
  • Start date Start date
J

Juan Gabriel Del Cid

Just use the "is" operator, like so:

if (myObject is Control) {
// myObject is a Control
}

Hope that helps,
-JG
 
How do I know if a class is descendent of another one,
not necessaraly his direct parent ?
In my case, I need to know if a certain class descends
from Control.
Thanks for any help.

_____
Marco
 
Juan Gabriel Del Cid said:
Just use the "is" operator, like so:

if (myObject is Control) {
// myObject is a Control
}

That works for an *instance* of a type. If Marco needs to know the
information just from the type itself, he could use:

if (typeof(Control).IsAssignableFrom (testType))
{
....
}
 
Back
Top