Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
C# Overriding example using virtual and override keywords
//Rextester.Program.Main is the entry point for your code. Don't change it. //Compiler version 4.0.30319.17929 for Microsoft (R) .NET Framework 4.5 using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; namespace Rextester { public class Program { public static void Main(string[] args) { //Your code goes here Console.WriteLine("Hello, world!"); A a = new A(); a.Method(); B b = new B(); b.Method(); A ab = new B(); ab.Method(); B bc = new C(); bc.Method(); } class A{ public virtual void Method() { Console.WriteLine("A"); } } class B:A{ public override void Method() { Console.WriteLine("B"); } } class C:B{ public void Method() { Console.WriteLine("C"); } } } }
run
|
edit
|
history
|
help
0
Cells with Odd Values in a Matrix
sdefuy6j87uytgr
23
dlritytio
Plt-D v.0.8.4
Plt-D v.0.9
Primes
Interface fully qualified names
Cotton Farm 0.0.2.02
Convert string to TimeSpan in C#