All pastes #897109 Raw Edit

Untitled

public text v1 · immutable
·published 2008-02-09 06:25 UTC
rendered paste body
using System;

public class A {
}

public class B : A {
}

static class MultiMaybeMethods {
	public static void Mumble (this int i, string x) {
		Console.WriteLine (x);
	}
	public static void Mumble (this int i, int x) {
		Console.WriteLine (x);
	}
	public static void Mumble (this int i, A a ) {
		Console.WriteLine (a);
	}
	public static void Mumble (this int i, B b ) {
		Console.WriteLine (b);
	}
	public static void Mumble (this int i, object o) {
		Console.WriteLine (o);
	}
}

class Foo {
	public void Bumble (string x) {
		Console.WriteLine (x);
	}
	public void Bumble (int x) {
		Console.WriteLine (x);
	}
	public void Bumble (A a ) {
		Console.WriteLine (a);
	}
	public void Bumble (B b ) {
		Console.WriteLine (b);
	}
	public void Bumble (object o) {
		Console.WriteLine (o);
	}

	public void DoStuff (int i, object o) {
		i.Mumble (o);
		Bumble (o);
	}

	public static void Main (string[] args) {
		int i = 2;
		Foo m = new Foo ();

		i.Mumble ("hi");
		m.Bumble ("hi");
		i.Mumble (5);
		m.Bumble (5);
		i.Mumble (new A());
		m.Bumble (new A());
		i.Mumble (new B());
		m.Bumble (new B());
		i.Mumble ((A)(new B()));
		m.Bumble ((A)(new B()));
		m.DoStuff (i, new B());
	}
}