Creating structures with Reflection

  • Thread starter Thread starter Nigel Findlater
  • Start date Start date
N

Nigel Findlater

Hallo,

Does anyone have a simple example of how to create a
structure with reflection?

Nigel...
 
"create a structure" means "instantiate a type" ?
which can be done with reflection.
To do this you only need to call a constructor of the type.

Assuming you have loaded the assembly from somewhere, something like this
would work:

object o = assembly.CreateInstance(FullyQualifiedTypeName,
false,
System.Reflection.BindingFlags.Public |
System.Reflection.BindingFlags.Instance |
System.Reflection.BindingFlags.InvokeMethod,
null,
(object[])args.ToArray(typeof(object)),
null,
null);


or instead by "create a structure" maybe you mean "create a new type" ?
This is something you would do with CodeDom.
 
Back
Top