Guest User

Untitled

a guest
Jul 19th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. class Test<K,V> {}
  2.  
  3. class Test1 : Test<int, string> {}
  4.  
  5. using System.Reflection;
  6.  
  7. ...
  8.  
  9. Type[] generics = typeof(Test1)
  10. .BaseType // Test<K, V>
  11. .GetGenericArguments(); // {K, V}
  12.  
  13. Console.Write(string.Join(", ", generics.Select(t => t.Name)));
  14.  
  15. Int32, String
  16.  
  17. Test1 myTest = ...
  18.  
  19. Type[] generics = myTest
  20. .GetType() // Test1
  21. .BaseType // Test<K, V>
  22. .GetGenericArguments(); // {K, V}
Add Comment
Please, Sign In to add comment