Home All Groups Group Topic Archive Search About

ask if a class inherits from another

Author
1 Apr 2005 1:08 AM
Rodolfo
I need to do something like this

public class a : b{
....

}
....
a objecta = new a();

if (objecta "inheritsfrom" b)
    do something;

There's a reserved word to do that?

TIA

Author
1 Apr 2005 1:32 AM
The Last Gunslinger
Rodolfo wrote:
Show quoteHide quote
>    I need to do something like this
>
> public class a : b{
> ...
>
> }
> ...
> a objecta = new a();
>
> if (objecta "inheritsfrom" b)
>     do something;
>
> There's a reserved word to do that?
>
> TIA
>
>
>
>
if(objecta is b)// I think
or
b B = objecta as b;
if(!B is null)
//objecta inherits from b

HTH
JB

Bookmark and Share