Console.WriteLine(arCars[pos].PetName);
}
}
Notice that once you constrain CarCollection
such that it can contain only Car-derived
types, the implementation of PrintPetName() is straightforward, given that the compiler now
assumes is a Car-derived type. Furthermore, if the specified type parameter is not Car-
compatible, you are issued a compiler error:
Do'stlaringiz bilan baham: