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
D19
encryption
Hex_Base64
Test equality
Parse SQL Insert
Shorten SMS Text
Remove BOLD formatting from html
Bases5
first
Q-2 dotnet