title: Foreach can throw an InvalidCastException?
body: <p>Imagine the following code:</p>
  
  <pre><code>class foreach_convert
  {
      public static void method2()
      {
          List&lt;IComparable&gt; x = new List&lt;IComparable&gt;();
          x.Add(5);
  
          foreach (string s in x)
          {
              //InvalidCastException in runtime
          }
      }
  }
  </code></pre>
  
  <p>I wonder, why is this foreach behavior so... not C#-like?
  What happens here is an implicit cast to a subclass, which is error-prone and seems to be banned in every other place in the language. Or am I not right?</p>
  
  <p>P.S. The reason I'm asking is that I had a bug in the similar code in my project, where I used to iterate through a custom Collection from an external library, which was called like <code>SomeTypeCollection</code>, but in fact provided a collection of base type items and could have contained items of <code>SomeOtherType</code>. My fault, but still neither the language, nor the compiler provided any explicit hints/warnings, which is quite unusual for C#... </p>