error: type List does not take parameters
You are likely importing java.awt.List. You should instead import java.util.List, which is a parameterized type.
You are likely importing java.awt.List. You should instead import java.util.List, which is a parameterized type.
This is not a type erasure problem per se, but almost the opposite: You get a problem at runtime, when the system knows the actual types, but not at compile time. The reason why this compiles is that List is an interface. As far as the compiler is concerned, a subclass of String might actually … Read more
Use Type.GetGenericArguments. For example: using System; using System.Collections.Generic; public class Test { static void Main() { var dict = new Dictionary<string, int>(); Type type = dict.GetType(); Console.WriteLine(“Type arguments:”); foreach (Type arg in type.GetGenericArguments()) { Console.WriteLine(” {0}”, arg); } } } Output: Type arguments: System.String System.Int32