"Ondrej Sevecek" <on***@sevecek.com> wrote in
news:#Q**************@TK2MSFTNGP09.phx.gbl:
Hello,
how to create an instance of some object class by using the class's
name? For example, I want to fulfill this pseudocode:
class MyNewClass
{
...
}
Object NewInstanceOfClass = new
CreateTheObjectByClassName("MyNewClass");
Many thanks in advance
Ondra.
using System.Reflection;
//if the containing assembly is already loaded
Activator.CreateInstance("MyNamespace.MyClass");
//if the assembly should be loaded at runtime
Assembly a = Assembly.Load(............)
object obj = a.CreateInstance("MyNamespace.MyClass");
--
best regards
Peter Koen
-----------------------------------
MCAD, CAI/R, CAI/S, CASE/RS, CAT/RS
http://www.kema.at