关于 T[] 的反射问题
1. T[] 类型不适应以下代码
Dictionary<string, Test> d = new Dictionary<string, Test>(); // Get a Type object representing the constructed type. // Type constructed = d.GetType(); DisplayTypeInfo(constructed); Type generic = constructed.GetGenericTypeDefinition();
http://msdn.microsoft.com/en-us/library/system.type.getgenerictypedefinition.aspx
如果我们使用 typeof(int[]).GetGenericTypeDefinition 将被抛出一个异常,表明T[]不是一个泛型,无法获得类似 typeof(T[]) 的泛型Type
2. 反射T[] 应当使用 typeof(int).MakeArrayType
var arr = Activator.CreateInstance(tpArray,10) as Array;