Created
October 7, 2016 19:00
-
-
Save thomaswatters/1244844e9327a177e807923c069e6383 to your computer and use it in GitHub Desktop.
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
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