Hi there,
I want to achieve something like this. Please let me know if it is possible or not.
Java
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 Bhurke3 pointsPosted Sep 18, 2007, 12:10 AM EDT
Got the solution.. thanks..
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();