Question: I'm looking to compare a value against a list and then set another variable based on this comparison.

My list is

```
1 = Red
4 = Blue
13 = Green

```

I could have a series of if statements but with a large list this looks messy

```
if (Type == 1)
{
    Name = "Red";
}
else if (Type == 4)
{
    Name = "Blue";
}
else if (Type == 13)
{
    Name = "Green";
}

```

What's an efficient and tidy way to achieve the same?

Answer: 
Make use of dictionary store your values, it will make clean code with less line of code and readable too

```
Dictionary<int, string> data = new Dictionary<int, string>
{
    { 1, "Red" }, 
    { 4, "Blue" },
    { 13, "Green" }
};

string test;
if (data.TryGetValue(1, out test)) // Returns true.
{
   Console.WriteLine(test); 
}

```
I think you need to use switch here:

```
switch (Type)
  {
      case 1:
          Name = "Red";
          break;
      case 4:
          Name = "Blue";
          break;
      case 13:
          Name = "Green";
          break;
  }

```