Problem with virtual method

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jon Davis

    #1

    Problem with virtual method

    If I have a class with a virtual method, and a child class that overrides
    the virtual method, and then I create an instance of the child class AS A
    base class...

    BaseClass bc = new ChildClass();

    .... and then call the virtual method, why is it that the base class's method
    is called instead of the overridden method? How do I fix this if I don't
    know at compile-time what the child class is? I'm using
    Activator.Creat eInstance() to load the child class from a satellite DLL, a
    third-party plug-in that inherits my base class, so I therefore cannot
    declare the child class type in the code or at compile time.

    Thanks,
    Jon


Working...