Skip to content

Instantly share code, notes, and snippets.

@alexdresko
Created November 7, 2013 17:54
Show Gist options
  • Select an option

  • Save alexdresko/7358904 to your computer and use it in GitHub Desktop.

Select an option

Save alexdresko/7358904 to your computer and use it in GitHub Desktop.
Pair for Eric Lippert
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