Created
August 13, 2020 13:22
-
-
Save nanwang2016/0ca207b091305b48835825e7f08ae699 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
namespace TestFile | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
var animal = new Animal(); | |
var cat = new Cat(); | |
animal.Eat(); | |
cat.Eat(); | |
} | |
} | |
public class Animal | |
{ | |
public string name { get; set; } | |
public Animal() | |
{ | |
} | |
public virtual void Eat() | |
{ | |
Console.WriteLine("The animal eats food!"); | |
} | |
} | |
public class Cat: Animal | |
{ | |
public Cat() | |
{ | |
} | |
public override void Eat() | |
{ | |
Console.WriteLine("The cat eats fish!"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment