Created
October 12, 2018 18:04
-
-
Save qassa/05ea3ad39589578431b3c880736145b5 to your computer and use it in GitHub Desktop.
short ways
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
using System; | |
using System.Collections.Generic; | |
namespace SharpDelegateSwitch | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
Dictionary<int, Action> vars = new Dictionary<int, Action>(); | |
vars.Add(1, () => { /*Console.WriteLine("1 was generated");*/ }); | |
vars.Add(2, () => { }); | |
vars.Add(3, () => { }); | |
vars.Add(4, () => { }); | |
vars.Add(5, () => { }); | |
Random r = new Random(); | |
Action ac = vars[r.Next(1, 5)]; | |
ac(); | |
switch (r.Next(1, 5)) | |
{ | |
case 1: | |
break; | |
case 2: | |
break; | |
case 3: | |
break; | |
case 4: | |
break; | |
case 5: | |
break; | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment