title: How to enumerate an enum
body: <p>How can you enumerate an <code>enum</code> in C#?</p>
  
  <p>E.g. the following code does not compile:</p>
  
  <pre class="lang-cs prettyprint-override"><code>public enum Suit
  {
      Spades,
      Hearts,
      Clubs,
      Diamonds
  }
  
  public void EnumerateAllSuitsDemoMethod()
  {
      foreach (Suit suit in Suit)
      {
          DoSomething(suit);
      }
  }
  </code></pre>
  
  <p>And it gives the following compile-time error:</p>
  
  <blockquote>
    <p>'Suit' is a 'type' but is used like a 'variable'</p>
  </blockquote>
  
  <p>It fails on the <code>Suit</code> keyword, the second one.</p>