Hi there,
I want to achieve something like this. Please let me know if it is possible or not.
string strType = "System.String";
//I want to create List of actual type mentioned in the strType value.
List<strType> obj = new List<strType>();
Awaiting your reponse.
Paresh
Paresh BhurkePosted Sep 18, 2007, 4:10 AM
string typeName = "System.String";
Type listType = typeof(List<>);
Type listElementType = Type.GetType(typeName);
Type genericType = listType.MakeGenericType(listElementType);
IList lobjlist = (IList)Activator.CreateInstance(genericType);
Console.WriteLine(lobjlist.Count.ToString());
lobjlist.Add("Paresh");
Console.WriteLine(lobjlist.Count.ToString());
Console.ReadKey();