title: Casting string to IEnumerable<object>
body: <p>I have <code>propertyValue</code> which is an object passed into my function. </p>
  
  <p>I can assume that this is an <code>IEnumerable</code> of some kind, however due to the interface contract I must accept it as an <code>object</code> rather than directly as an <code>IEnumerable</code>.</p>
  
  <p>When I try to cast my value to an <code>IEnumerable&lt;object&gt;</code>, so that I can get the length, I get an <code>InvalidCastException</code>.</p>
  
  <pre><code>var length = ((IEnumerable&lt;object&gt;) propertyValue).Cast&lt;object&gt;().Count();
  </code></pre>
  
  <p>I get the following exception:</p>
  
  <blockquote>
    <p>System.InvalidCastException: Unable to cast object of type
    'System.String' to type
    'System.Collections.Generic.IEnumerable`1[System.Object]'.</p>
  </blockquote>