Class inference
-
Hi, I need to determine the parent class from which a particular subclass is derived. Could someone kindly explain to me how I can access that information please? Regards, Dave
Regards, Dave
Well this is something you should know at design time, not in code. Why would you need to check in code when a class in C# can only have one parent class ? Can you better explain what you're trying to do ? The is and as keywords let you do stuff like if ( x is mybase) which returns true if the object x is a mybase, either directly or as a parent.
Christian Graus Driven to the arms of OSX by Vista.
-
Hi, I need to determine the parent class from which a particular subclass is derived. Could someone kindly explain to me how I can access that information please? Regards, Dave
Regards, Dave
-
Hi, I need to determine the parent class from which a particular subclass is derived. Could someone kindly explain to me how I can access that information please? Regards, Dave
Regards, Dave
if you have an instance of that class:
object unknown = ?;
Type unknownType = unknown.GetType();
Type toFind = unknownType.BaseType;The variable
Type
will hold the type your class directly inherits from. I hope this answers your question.