title: Objects of a specific type in foreach from an IEnumerable
body: <p>I'm working with a legacy collection object that only implements non-generic <code>IEnumerable</code> and <code>ICollection</code>. What exactly happens with this object when I try to use this object with a <code>foreach</code> giving a more specific type on the LHS of the foreach expression?</p>
  
  <pre><code>// LegacyFooCollection implements non-generic IEnumerable
  LegacyFooCollection collection = GetFooCollection();
  foreach (Foo f in collection)
  {
      // etc.
  }
  </code></pre>
  
  <p>I know (because I've tried it) that this is safe when everything in <code>collection</code> really is of type <code>Foo</code>, but what happens if that fails?</p>