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); 
}

```
```
    class Program
    {
        public enum EnumDisplayStatus
        {
            Red = 1,
            Blue = 2,
            Yellow = 3,
            Orange = 4
        }
        static void Main()
        {
            int value = 3;
            EnumDisplayStatus enumDisplayStatus = (EnumDisplayStatus)value;
            string color = enumDisplayStatus.ToString();
            Console.Write(color);
        }
    }

```

Use enum and get string with this way that I showed.