title: enum case handling - better to use a switch or a dictionary?
body: <p>When handling the values of an enum on a case by case basis, is it better to use a switch statement or a dictionary?</p>
  
  <p>I would think that the dictionary would be faster.  In terms of space, it takes up some in memory, but the case statement would also take up some memory just in the memory needed for the program itself.  So bottom line I'm thinking it's always better to just use the dictionary.</p>
  
  <p>Here are the two implementations side by side for comparison:</p>
  
  <p>Given these enums:</p>
  
  <pre><code>enum FruitType
  {
      Other,
      Apple,
      Banana,
      Mango,
      Orange
  }
  enum SpanishFruitType
  {
      Otra,
      Manzana, // Apple
      Naranja, // Orange
      Platano, // Banana
      Pitaya // Dragon fruit, only grown in Mexico and South American countries, lets say
      // let's say they don't have mangos, because I don't remember the word for it.
  }
  </code></pre>
  
  <p>Here is the way to do it with the switch statement:</p>
  
  <pre><code>private static SpanishFruitType GetSpanishEquivalent(FruitType typeOfFruit)
  {
      switch(typeOfFruit)
      {
          case FruitType.Apple:
              return SpanishFruitType.Manzana;
          case FruitType.Banana:
              return SpanishFruitType.Platano;
          case FruitType.Orange:
              return SpanishFruitType.Naranja;
          case FruitType.Mango:
          case FruitType.Other:
              return SpanishFruitType.Otra;
          default:
              throw new Exception("what kind of fruit is " + typeOfFruit + "?!");
      }
  }
  </code></pre>
  
  <p>And here is how it is done with a dictionary:</p>
  
  <pre><code>private static Dictionary&lt;FruitType, SpanishFruitType&gt; EnglishToSpanishFruit = new Dictionary&lt;FruitType, SpanishFruitType&gt;()
  {
      {FruitType.Apple, SpanishFruitType.Manzana}
      ,{FruitType.Banana, SpanishFruitType.Platano}
      ,{FruitType.Mango, SpanishFruitType.Otra}
      ,{FruitType.Orange, SpanishFruitType.Naranja}
      ,{FruitType.Other, SpanishFruitType.Otra}
  };
  private static SpanishFruitType GetSpanishEquivalentWithDictionary(FruitType typeOfFruit)
  {
      return EnglishToSpanishFruit[typeOfFruit]; // throws exception if it's not in the dictionary, which is fine.
  }
  </code></pre>
  
  <p>Not only does the dictionary have the speed boost, it also has less unnecessary strings in the code.  Is this always better to use the dictionary then?  Is there even a third better way?</p>
  
  <p>Thanks in advance.</p>