Virtual_override_override.cs
using System;using System.Collections.Generic;using System.Text;namespace ConsoleApplication1{class Overriding{}class basecalss{public virtual void virtual_method(){Console.WriteLine("Virtual in baseclass");} }class derivedclass1 : basecalss{public override void virtual_method(){Console.WriteLine("Override in dervied class1");}}class derivedclass2 : derivedclass1{public override void virtual_method(){Console.WriteLine("Override in dervied class2");}}class implement_override // UNCOMMENT THE MAIN FUNCTION{public static void Main(){basecalss baseobj;derivedclass1 derobj1 = new derivedclass1();baseobj = derobj1;baseobj.virtual_method();derivedclass2 derobj2 = new derivedclass2();baseobj = derobj2;baseobj.virtual_method();Console.ReadLine(); }}}/////////////////////////////////////////////////Virtual_virtual_override.cs//using System;//using System.Collections.Generic;//using System.Text;//namespace ConsoleApplication1//{// class Overriding// {// }// class basecalss// {// public virtual void virtual_method()// {// Console.WriteLine("Virtual in baseclass");// } // }// class derivedclass1 : basecalss// {// public new virtual void virtual_method()// {// Console.WriteLine("Override in dervied class1");// }// }// class derivedclass2 : derivedclass1// {// public override void virtual_method()// {// Console.WriteLine("Override in dervied class2");// }// }// class implement_override // UNCOMMENT THE MAIN FUNCTION// {// public static void Main()// {// basecalss baseobj;// derivedclass1 derobj1 = new derivedclass1();// baseobj = derobj1;// baseobj.virtual_method();// derivedclass2 derobj2 = new derivedclass2();// baseobj = derobj2;// baseobj.virtual_method();// Console.ReadLine(); // }// }//}