title: foreach with generic List, detecting first iteration when using value type
body: <p>When <code>foreach</code>ing through a generic list I often want to do something different for the first element in the list:</p>
  
  <pre><code>List&lt;object&gt; objs = new List&lt;object&gt;
  {
      new Object(),
      new Object(),
      new Object(),
      new Object()
  };
  
  foreach (object o in objs)
  {
      if (o == objs.First())
      {
          System.Diagnostics.Debug.WriteLine("First object - do something special");
      }
      else
      {
          System.Diagnostics.Debug.WriteLine("object Do something else");
      }
  }
  </code></pre>
  
  <p>This will output:</p>
  
  <pre>
      First object - do something special
      object Do something else
      object Do something else
      object Do something else
  </pre>
  
  <p>This is all fine and dandy.</p>
  
  <p>However if my generic list is of a value type, this approach will fail.</p>
  
  <pre><code>List&lt;int&gt; ints = new List&lt;int&gt; { 0, 0, 0, 0 };
  foreach (int i in ints)
  {
      if (i == ints.First())
      {
          System.Diagnostics.Debug.WriteLine("First int - do something special");
      }
      else
      {
          System.Diagnostics.Debug.WriteLine("int Do something else");
      }
  }
  </code></pre>
  
  <p>This will output:</p>
  
  <pre>
      First int - do something special
      First int - do something special
      First int - do something special
      First int - do something special
  </pre>
  
  <p>Now I know I could recode this to add a <code>boolean</code> flag variable or traditional <code>for</code> loop, but I am wondering if there's any way to find out if a foreach loop is on the first iteration of its looping.</p>