Using a type builder I am OK with creating a type dynamically. Would it be possible to do this from an anonymous type?
I have this so far;
//CreateType generates a type (so that I can set it's properties once instantiated) from an //anonymous object. I am not interested in the initial value of the properties, just the Type.
Type t = CreateType(new {Name = "Ben", Age = 23});
var myObject = Activator.CreateInstance(t);
Is it possible to now use Type "t" as a type argument?
My method:
public static void DoSomething<T>() where T : new()
{
}
I would like to call this method using the dynamically created Type "t". So that I can call;
DoSomething<t>(); //This won't work obviously