we know overriding is the concepts of OOPS which is implement using abstract method and virtual class keyword . for more description goto https://msdn.microsoft.com/en-us/library/ebca9ah3.aspx . Let's see on virtual and override keywords in C# .
try to how can do show below
using System;
namespace Verriding { class first { public virtual void method() { Console.WriteLine("called class first method()"); } }
class second : first { public override void method() { Console.WriteLine("called class second method()"); } }
class third : second { public override void method() { Console.WriteLine("called class third method()"); } }
class Program { static void Main(string[] args) {
first a = new first(); second b = new second(); third c = new third(); a.method(); // output --> "first::method()" b.method(); // output --> "second::method()" c.method(); // output --> "third::method()"
a = new second(); a.method(); // output --> "second::method()" b = new third(); b.method(); // output --> "third::method()"
Console.ReadKey(); } } }
Markdown for AI
A clean, structured version of this page for AI assistants and LLMs.
We use cookies to ensure you have the best browsing experience on our website. By using our site, you
acknowledge that you have read and understood our
Cookie Policy &
Privacy Policy.
we know overriding is the concepts of OOPS which is implement using abstract method and virtual class keyword . for more description goto https://msdn.microsoft.com/en-us/library/ebca9ah3.aspx .
Let's see on virtual and override keywords in C# .
try to how can do show below