title: IEnumerable of variable type
body: <p>In the below example I have a method called GetList that takes a single string parameter and returns a List entities. I capture this in a generic IEnumerable variable because at runtime I have no idea what entity the user may want. How can I use the actual type instead of object? </p>
  
  <p>I want to replace this...</p>
  
  <pre><code>IEnumerable&lt;object&gt; data = GetList(entityName);
  </code></pre>
  
  <p>With this...</p>
  
  <pre><code>IEnumerable&lt;Company&gt; data = GetList(entityName);
  </code></pre>
  
  <p>The only way I can think of handling it right now which I'm NOT going to do because we have 300+ entities is something like</p>
  
  <pre><code>switch(entitName)
  {
    case "Company":
     IEnumerable&lt;Company&gt; data = GetList(entityName);
     break;
  
    case "Employee":
     IEnumerable&lt;Employee&gt; data = GetList(entityName);
     break;
  
     ...
  }
  </code></pre>