title: Generic foreach loop in C#
body: <p>The compiler, given the following code, tells me "Use of unassigned local variable 'x'."  Any thoughts?</p>
  
  <pre><code>public delegate Y Function&lt;X,Y&gt;(X x);
  
  public class Map&lt;X,Y&gt;
  {
      private Function&lt;X,Y&gt; F;
  
      public Map(Function f)
      {
          F = f;
      }
  
      public Collection&lt;Y&gt; Over(Collection&lt;X&gt; xs){
          List&lt;Y&gt; ys = new List&lt;Y&gt;();
          foreach (X x in xs)
          {
              X x2 = x;//ys.Add(F(x));
          }
          return ys;
      }
  }
  </code></pre>