mirror of
https://github.com/Smaug123/WoofWare.PawPrint
synced 2025-10-19 04:08:39 +00:00
23 lines
407 B
C#
23 lines
407 B
C#
public class Program
|
|
{
|
|
public class Animal
|
|
{
|
|
public int Age { get; set; }
|
|
}
|
|
|
|
public class Dog : Animal
|
|
{
|
|
public string Name { get; set; }
|
|
}
|
|
|
|
public static int Main(string[] args)
|
|
{
|
|
Dog myDog = new Dog { Age = 5, Name = "Rex" };
|
|
|
|
// Cast to base class - should succeed
|
|
Animal animal = (Animal)myDog;
|
|
|
|
return animal.Age;
|
|
}
|
|
}
|