Skip to content

Instantly share code, notes, and snippets.

@tnngo2
Created April 12, 2012 10:13
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 tnngo2/2366263 to your computer and use it in GitHub Desktop.
Save tnngo2/2366263 to your computer and use it in GitHub Desktop.
class Animal
{
public void Eat()
{
Console.WriteLine("Every animal eats something");
}
private virtual void DoSomething()
{
Console.WriteLine("Every animal does something");
}
}
class Cat : Animal
{
public override void DoSomething()
{
Console.WriteLine("Every animal does something in derived class ");
}
static void Main(string[] args)
{
Cat objCat = new Cat();
objCat.Eat();
objCat.DoSomething();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment