Last active
June 11, 2018 15:23
-
-
Save YannMjl/f314d2127bc017087a99f379413995d5 to your computer and use it in GitHub Desktop.
Polymorphism: Late biding or Overriding example
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 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