Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Test<K,V> {}
- class Test1 : Test<int, string> {}
- using System.Reflection;
- ...
- Type[] generics = typeof(Test1)
- .BaseType // Test<K, V>
- .GetGenericArguments(); // {K, V}
- Console.Write(string.Join(", ", generics.Select(t => t.Name)));
- Int32, String
- Test1 myTest = ...
- Type[] generics = myTest
- .GetType() // Test1
- .BaseType // Test<K, V>
- .GetGenericArguments(); // {K, V}
Add Comment
Please, Sign In to add comment