Created
August 29, 2018 17:59
-
-
Save Pharap/d5aaf12c0e41f1fa06e3b51ec3c6711d to your computer and use it in GitHub Desktop.
Weird C# quirk
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
namespace ConsoleApplication1 | |
{ | |
class Program | |
{ | |
public class Base | |
{ | |
public virtual void Foo(int a, int b) { } | |
} | |
public class Derived : Base | |
{ | |
public override void Foo(int b, int a) | |
{ | |
Console.WriteLine("a = {0}, b = {1}", a, b); | |
} | |
} | |
static void Main(string[] args) | |
{ | |
Derived d = new Derived(); | |
d.Foo(a: 1, b: 2); | |
Base b = d; | |
b.Foo(a: 1, b: 2); | |
Console.ReadKey(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment