Seeing as C# can\'t switch on a Type (which I gather wasn\'t added as a special case because is relationships mean that more than one distinct
switch
is
You can create overloaded methods:
void Foo(A a) { a.Hop(); } void Foo(B b) { b.Skip(); } void Foo(object o) { throw new ArgumentException("Unexpected type: " + o.GetType()); }
And cast the argument to dynamic type in order to bypass static type checking:
Foo((dynamic)something);