Created
November 7, 2013 17:54
-
-
Save alexdresko/7358904 to your computer and use it in GitHub Desktop.
Pair for Eric Lippert
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
| void Main() | |
| { | |
| var result = GetStatusMessage(40); | |
| } | |
| struct Pair<T, V> | |
| { | |
| public T Key; | |
| public V Value; | |
| } | |
| public string GetStatusMessage(int value) | |
| { | |
| var config = new List<Pair<int[], string>> | |
| { | |
| { new Pair<int[], string> { Key = new [] { 1, 2, 3 }, Value = "OK" } }, | |
| { new Pair<int[], string> { Key = new [] { 10 }, Value = "Out of disk space" } } , | |
| { new Pair<int[], string> { Key = new [] { 20 }, Value = "Keyboard not attached" } }, | |
| { new Pair<int[], string> { Key = new [] { 30 }, Value = "Mouse not Attached" } }, | |
| { new Pair<int[], string> { Key = new [] { 40 }, Value = "RAM Faulty" } } | |
| }; | |
| return config.Single (c => c.Key.Contains(value)).Value; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment