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

Popular posts from this blog

html5 - What is breaking my page when printing? -

html - Unable to style the color of bullets in a list -

c# - must be a non-abstract type with a public parameterless constructor in redis -