反射-从System.Type实例获取通用参数 [英] Reflection - Getting the generic arguments from a System.Type instance
本文介绍了反射-从System.Type实例获取通用参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如果我有以下代码:
MyType<int> anInstance = new MyType<int>();
Type type = anInstance.GetType();
我如何找出"anInstance"是哪种类型的参数?通过查看类型变量来实例化?有可能吗?
How can I find out which type argument(s) "anInstance" was instantiated with, by looking at the type variable? Is it possible?
推荐答案
查看全文