Skip to content

Instantly share code, notes, and snippets.

@YannMjl
Last active June 11, 2018 15:23
Show Gist options
  • Save YannMjl/f314d2127bc017087a99f379413995d5 to your computer and use it in GitHub Desktop.
Save YannMjl/f314d2127bc017087a99f379413995d5 to your computer and use it in GitHub Desktop.
Polymorphism: Late biding or Overriding example
using System;
namespace polymorphismExample
{
public class parentClass
{
public virtual void Display()
{
Console.WriteLine("Hello! My name is Yann!");
}
}
public class childClass:parentClass
{
public override void Display()
{
Console.WriteLine("Hello! Nice to meet you!");
}
}
public class Program
{
static void Main(string[] args)
{
parentClass obj = new childClass();
obj.Display()
Console.ReadKey();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment