Hello all,

In C#, how can I create an object whoose type is not known until run-time?
I need something similar to MFC's "RUNTIME_CLASS(CXxx).CreateObject()".

I expect it to look something like this, where the method will then
create an instance of the class and work with it.

public void ShowDialog(Type dialogClass)
{
   if (!dialogClass.IsSubclassOf(typeof(Dialog)))
      throw new ApplicationException("Invalid type");
   .
   .
   .
}

Regards
Henrik

You can read messages from the DOTNET archive, unsubscribe from DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.

Reply via email to