Is this not what Type
is able to offer? Is there another way I can achieve the below?
Type t = typeof(Int32);
List<t> list = new List<t>();
This seems valid usage to me based on what the docs mentioned:
Represents type declarations: class types, interface types, array types, value types, enumeration types, type parameters, generic type definitions, and open or closed constructed generic types
But I have a feeling this is a better description which means that I cannot use the class Type
as above as it seems to only hold information about the type:
Type describes data types. It stores type information in a variable, property or field. The Type class represents the program's metadata, which is a description of its structure but not the instructions that are executed.
I was trying to use the above in order to solve a problem where I have a 'List' where t
is a user defined type, that list gets stored within a field of type object
I will at some point later on need to parse it back to it's original type, I was hoping that the class Type
will allow me to retain the type for parsing back to the original later on.
I am after something like this:
public IList ObjectToList(Type t, object o)
{
return new List<t>(o);
}