Creating a generic IList instance using reflection
asp.net, c#, reflection
Solution
you'll have to instatiate a concrete class so if you do
var type = Type.GetType(typeof (List<T>).AssemblyQualifiedName);
var list = (Ilist<T>)Activator.CreateInstance(type);
you will be succesfull (as long as you supply a valid value for T of course).
Problem
I am trying to create a generic list of objects using reflection. The below code throws an error Cannot create an instance of an interface. . I could change the IList to List and it works fine, but I was wondering if there is way to get this working with an IList. ``` var name = typeof (IList<T>).AssemblyQualifiedName; Type type = Type.GetType(name); var list = Activator.CreateInstance(type); ```