Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
string data = "Item1";
var action1 = new Action(() => { Console.Write("This is one!"); });
var action2 = new Action(() => { Console.Write("This is two!"); });
var action3 = new Action(() => { Console.Write("This is three!"); });
switch (data)
{
case "Item1":
action1();
break;
case "Item2":
action2();
break;
default:
action3();
break;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment