reflection - Create Dynamic class in c# -
string name = "register"; class<?> classobj = class.forname(name); statecomponent = (istate) classobj.newinstance();
this code creating dynamic class in java. can give me start how make dynamic class in c#?
c#'s class corresponds java's class<t>
system.type
. unlike java, type
not generic (it not need be, because .net not use type erasure implement generics).
your java code translates follows:
string name = "..."; // full name of class type typeobj = type.gettype(name); // default constructor constructorinfo constr = typeobj.getconstructor(new type[0]); // invoke constructor create object statecomponent = (istate)constr.invoke(new object[0]);
Comments
Post a Comment