I have a scenario on which i got Class name as a string
I just want to create a generic List
of that class. I tried the following
Type _type = Type.GetType(className);
List<_type> list = new List<_type>();
But iam geting error
. I can't gave that _type as list argument. If anybody knows please help me
Closest you can get:
Type listType = typeof(List<>).MakeGenericType(_type);
IList list = (IList) Activator.CreateInstance(listType);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With