Skip to content

Instantly share code, notes, and snippets.

@nanwang2016
Created August 13, 2020 13:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nanwang2016/0ca207b091305b48835825e7f08ae699 to your computer and use it in GitHub Desktop.
Save nanwang2016/0ca207b091305b48835825e7f08ae699 to your computer and use it in GitHub Desktop.
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