Skip to content

Instantly share code, notes, and snippets.

@Pharap
Created August 29, 2018 17:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Pharap/d5aaf12c0e41f1fa06e3b51ec3c6711d to your computer and use it in GitHub Desktop.
Save Pharap/d5aaf12c0e41f1fa06e3b51ec3c6711d to your computer and use it in GitHub Desktop.
Weird C# quirk
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