Dynamic List<T> type

.net, c#, dynamic

Solution

It's possible, but not necessarily useful, since you couldn't actually use it from compiled code as strongly typed. The creation code would be

    Type myType;
    Type listType = typeof(List<>).MakeGenericType(myType);
    IList myList = (IList)Activator.CreateInstance(listType);

Problem

Is it possible to create a new `List<T>` where the T is dynamically set at runtime? Cheers

Original source

Related problems