Runtime Type Determination

  • Thread starter Christopher Pragash
  • Start date
C

Christopher Pragash

I have two subclass deriving from a common base class. The base class
exposes two shared functions for serialization and deserialization in XML
format and some other methods that are overrided by the derived classes. I
want to be able to serialize and deserialize the derived classes through the
methods in the base class, without explicitly passing the type of the
object. I want to determine at runtime the type of the derived class calling
the function and Serialize and deserialize based on that type. How do I
achieve this?

For example:

The client will call ObjA.Serialize(), where objA is a derived class and
Serialize is a method implemented in the parent class. How do I determine
the type of the derived class calling the Function? Is there an inbuilt
mechanism, like Reflection etc..., that could help in this mechanism?

Thanks in advance,
regards,
Chris
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top