Skip to content

Instantly share code, notes, and snippets.

@thomaswatters
Created October 7, 2016 19:00
Show Gist options
  • Save thomaswatters/1244844e9327a177e807923c069e6383 to your computer and use it in GitHub Desktop.
Save thomaswatters/1244844e9327a177e807923c069e6383 to your computer and use it in GitHub Desktop.
interface WTF
{
Type type;
}
enum Type
{
A,
B
}
interface A : WTF
{
Type type = Type.A;
void MethodA();
}
interface B : WTF
{
Type type = Type.B;
void MethodB();
}
void Foo(List<WTF> list)
{
foreach(var i in list)
{
switch(i.type)
{
case Type.A:
A a = (A)i;
a.MethodA();
break;
case Type.B:
B b = (B)i;
b.MethodB();
break;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment