Last active
November 29, 2019 22:46
-
-
Save fredyfx/c87282bf269024a3f9a410097b9d5360 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// nasty.. | |
switch(MyObj.GetType.ToString()){ | |
case "Type1": etc | |
} | |
// clumsy... | |
if myObj is Type1 then | |
if myObj is Type2 then |
This file contains hidden or 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
var @switch = new Dictionary<Type, Action> { | |
{ typeof(Type1), () => ... }, | |
{ typeof(Type2), () => ... }, | |
{ typeof(Type3), () => ... }, | |
}; | |
@switch[typeof(MyType)](); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment