clinically-proven

Untitled

Nov 22nd, 2020
538
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2. namespace ConsoleApp3
  3. {
  4.     class BaseClass
  5.     {
  6.         public virtual void show()
  7.         {
  8.             Console.WriteLine("Base class");
  9.         }
  10.     }
  11.  
  12.     class DerivedClass : BaseClass
  13.     {
  14.         // overriding
  15.         public override void show()
  16.         {
  17.             Console.WriteLine("Derived class");
  18.         }
  19.     }
  20.     class SampleClass
  21.     {
  22.         // Main Method
  23.         public static void Main()
  24.         {
  25.             BaseClass BaseClassObject = new BaseClass();
  26.  
  27.             BaseClassObject.show();
  28.  
  29.             BaseClassObject = new DerivedClass();
  30.  
  31.             BaseClassObject.show();
  32.         }
  33.     }
  34. }
  35.  
RAW Paste Data