类:
class A
{
/*...*/
}
class B : A
{
/*...*/
}
Main:
List<B> BListReference = new List<B>()
{
/*...*/
}
List<A> AListReference;
AListReference = ((IEnumerable<A>) BListReference).ToList();
协变 记一下防止我忘了
类:
class A
{
/*...*/
}
class B : A
{
/*...*/
}
Main:
List<B> BListReference = new List<B>()
{
/*...*/
}
List<A> AListReference;
AListReference = ((IEnumerable<A>) BListReference).ToList();
协变 记一下防止我忘了