class Dog
{
}
class BullDog : Dog
{
}
class Program
{
static void Main()
{
Dog dog2 = new BullDog();
BullDog dog3 = new BullDog();
}
}
>
When you use the base type as the reference type, you can only call members that are defined on the base type. You need to cast in order to use the members of the supertype.
So, if BullDog
defined a DoNotRelease
method, you could not call it from a Dog
reference directly.
In terms of var
- it will infer the more specific type. So if using new BullDog()
the inferred type will be BullDog
.