The custom data binding model, know the parameter name and type of the interface, but how to use this type and define a variable, the following code
var typeName=bindingContext. ModelMetadata. ModelType. Name;
The Type T=the GetType (typeName);
Now I want to use T this type defines a variable, or so
T HouseModel=new T ();
But I don't know have this aspect of the c # syntax errors, grammar, consult tall person to give directions, thank you very much!
CodePudding user response:
The Activator. Createinstance (type);
Create an instance of a class as directed by the type
CodePudding user response: