我需要一种获取对象或类的“真实类型”的方法(在这种情况下是泛型类)..现在我得到的只是一个RuntimeType ..我已经在互联网上阅读但是我只是找不到只返回RuntimeType的答案..
答案 0 :(得分:1)
System.RuntimeType
是一个实现抽象System.Type
类的内部具体类。有关详细讨论,请参阅the accepted answer至What's the difference between System.Type and System.RuntimeType in C#?。所以,你看,正如svick在评论中所说,RuntimeType
是的真实类型。
您找不到不返回RuntimeType
对象的方法,因为GetType()
始终返回RuntimeType
个对象。您将永远无法获得不是某个更多派生类的实例的Type
对象,因为Type
是抽象的。
答案 1 :(得分:0)
propertyinfo.PropertyType.GetGenericArguments()应该给出一个通用参数列表。
它是一个列表,因为一个类可以有超过1个泛型。
更多信息:
http://msdn.microsoft.com/en-us/library/ms173128.aspx
和这里
http://msdn.microsoft.com/en-us/library/b8ytshk6.aspx