数组的协变
时间:2010-12-05 来源:hankskfc
eg:
class A{......};
class B:A{.......};
class Progam
{
static void Main()
{
A[] AArray1 =new A[3];
A[] AArray2 = new A[3];
AArray1[0]=new A();AArray1[1]=new A();AArray1[2]=new A();
//协变,
AArray2[0] = new B();AArray2[1] = new B();AArray2[2] = new B();
}
}
相关阅读 更多 +