I am trying to store an array of classes which I can initialise later on. I am trying to do it like so:
Type[] x = { className };
However, I am getting the following error:
‘myNamespace.className’ is a ‘type’ but it is used like a ‘variable’
Any guidance would be appreciated.
Use the
typeofoperator, which is used to obtain aSystem.Typefor a type.EDIT:
In response to your comment: to create an instance of the type from a
System.Type, use an appropriate overload of theActivator.CreateInstancemethod.E.g.
In your case, since you know the base-type of the class, you can of course cast the return-value to the base-type.