本来想用如下这种方法进行强制转换: List obj1 = new List{1,2,3}; List obj2 = (List)obj1; 但是,报错,说是无法将类型"System.Collections.Generic.List'l[System.Object]"的对象强制转换为类型"System.Collections.Generic.List'l[System.Int32]"
Limitations
限制
Variant type parameters can only be declared on interfaces and delegate types, due to a restriction in the CLR. Variance only applies when there is a reference conversion between the type arguments. For instance, an IEnumerable<int> is not an IEnumerable<object> because the conversion from int to object is a boxing conversion, not a reference conversion.