title: How to pass a IList<T> argument in a function
body: <p>I have this function :</p>
  
  <pre><code>public static IList&lt;T&gt; myFunction&lt;T&gt;(IList&lt;T&gt; listaCompleta, int numeroPacchetti)
  {
      return listaCompleta;
  }
  </code></pre>
  
  <p>but if I try to call it with :</p>
  
  <pre><code>IList&lt;SomeObject&gt; listPacchetti = (from SomeObject myso in SomeObjects
                                    select myso).ToList();
  
  listPacchetti = myFunction(listPacchetti, 1);
  </code></pre>
  
  <p>When I compile it says <code>The type arguments for method 'myFunction&lt;T&gt;(IList&lt;T&gt;, int)' cannot be inferred from the usage. Try specifying the type arguments explicitly.</code></p>
  
  <p>The fact is that I need to use a IList (or a collection indexes, not a IEnumerable) and I need to pass a generic object to the function (this time a <code>IList&lt;SomeObject&gt;</code>, next time maybe <code>IList&lt;AnotherObject&gt;</code>)</p>
  
  <p>Can I do it? Or what about it? I think that I cannot use IList as type argument...</p>
  
  <p><strong>EDIT</strong> - Complete code</p>
  
  <h3>I CALL THE FUNCTION FROM ANOTHER CLASS</h3>
  
  <pre><code>IList&lt;Packet&gt; listPacchetti = (from Packet pack in Packets
                                                 select pack).ToList();
  
  listPacchetti = Utility.Extracts&lt;Packet&gt;(listPacchetti, 6);
  </code></pre>
  
  <h3>CLASS WITH FUNCTION</h3>
  
  <pre><code>public class Utility
  {   
      public Utility()
      {
  
      }
  
      public static IList&lt;T&gt; Extracts&lt;T&gt;(IList&lt;T&gt; listaCompleta, int numeroPacchetti)    // HERE THERE IS THE LINE WITH WARNINGS
      {
          return listaCompleta;
      }
  }
  </code></pre>