title: Specified cast is not valid when trying to iterate through an IEnumerable<int> in C#
body: <p>so I am currently learning LINQ in C# and I was trying this <code>Cast&lt;&gt;</code> extension method which doesn't really seem to work out. When I try to iterate through the <code>IEnumerable&lt;int&gt;</code> values, it doesn't work it gives me the error : </p>
  
  <blockquote>
    <p>System.InvalidCastException("Specified cast is not valid"). </p>
  </blockquote>
  
  <p>This is the code:
  (I've also tried to cast the 'result' variable into an array with <code>ToArray()</code> but it still didn't work, regardless of what I tried)</p>
  
  <pre><code>List&lt;string&gt; strings = new List&lt;string&gt;(){ "1", "2", "3", "4", "5", "6", "7", "8", "9", "10 };
  IEnumerable&lt;int&gt; result = strings.Cast&lt;int&gt;();
  
  foreach(int number in result){
      Console.WriteLine(number);
  }
  
  Console.ReadKey();
  </code></pre>
  
  <p>I've also tried to use 'var' instead of 'int' when trying to iterate through the IEnumerable result variable but it still doesn't work out, Here is an image of what it shows me: </p>
  
  <p><a href="https://i.stack.imgur.com/ZfgUJ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ZfgUJ.png" alt="enter image description here"></a></p>