title: C# Passing a generic list into method and then casting to type
body: <p>I have a method that uses a list which I need to pass into it.</p>
  
  <p>Depending on where I call this method the type of the list is different.</p>
  
  <p>Is it possible to pass the list in as a generic list and then cast it to a certain type, or do I need to create parameters for every type of list that can be used (see below)?</p>
  
  <pre><code>public string MyMethod(List&lt;Type1&gt; list1, List&lt;Type2&gt; list2, ...etc )
      {
        switch(someCondition)
          {
            case 1:
             //pass list1 into a method from class1
            break;
            case 2: 
             //pass list2 into a method from class2
           break;
  
            ...//etc for several more lists
          }
  </code></pre>