Topic description
Override method. (console application)
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace override method { //Create a new class to store virtual methods class class1 { public virtual void Write() { Console.WriteLine("This is a virtual method, this can be overridden"); } } //Create a new inherited class to override the method class class2 : class1 { //override method public override sealed void Write()//Keyword sealed, I don't want the class inheriting class2 to override the Write() method { Console.WriteLine("This is an overridden method. It is called an overridden base method"); } } class Program { static void Main(string[] args) { class1 c1 = new class1(); c1.Write(); class2 c2 = new class2(); c2.Write(); } } }