I have a class with a property IEnumerable<T>
. How do I make a generic method that creates a new List<T>
and assigns that property?
IList list = property.PropertyType.GetGenericTypeDefinition()
.MakeGenericType(property.PropertyType.GetGenericArguments())
.GetConstructor(Type.EmptyTypes);
I dont know where is T
type can be anything