How to gettype list <String> in C #?
Possible duplicate:
How to get generic type from string representation?
How can I get type "List<String>" in C # using Type.GetType() ?
I have already tried:
Type.GetType("List<String>"); Type.GetType("System.Collections.Generic.List.String"); // Or [String] Please note that I cannot use typeof , since the value I get is a string.
You cannot get it from "List<String>" , but you can get it from Type.GetType :
Type type = Type.GetType("System.Collections.Generic.List`1[System.String]"); You are lucky in this case - both List<T> and string are in mscorlib, so we did not need to specify assemblies.
Parameter `1 defines the arity of the type: it has one type parameter. A bit in square brackets indicates type arguments.
Where do you get only List<String> ? Can you change your requirements? It will be easier than parsing a string, developing type parameters, searching for types in different namespaces and assemblies, etc. If you work in a limited context (for example, you only need to maintain a known set of types) it may be easiest to hard-code some details.
You can use typeof .
typeof(List<String>) affairs>
See this question: C # How to get a type from a string representation
System.Type type = typeof(List<String>); typeof(List<string>)