title: How do you call a generic method if you only know the type parameter at runtime?
body: <p>I have this method:</p>
  
  <pre><code>public List&lt;T&gt; SomeMethod&lt;T&gt;( params ) where T : new()
  </code></pre>
  
  <p>So I want to call this <code>SomeMethod</code> which is fine if I know the type:</p>
  
  <pre><code>SomeMethod&lt;Class1&gt;();
  </code></pre>
  
  <p>But if I only have <code>Class1</code> at runtime I'm unable to call it?</p>
  
  <p>So how to call <code>SomeMethod</code> with unknown T type? I got Type by using reflection.</p>
  
  <p>I have the Type of type but <code>SomeMethod&lt;Type | GetType()&gt;</code> doesn't work.</p>
  
  <p><strong>Update 7. May:</strong></p>
  
  <p>Here is a sample code of what I want to achieve:</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Text;
  using System.Reflection;
  
  namespace ConsoleApplication63
  {
      public class DummyClass
      {
      }
  
      public class Class1
      {
          public string Name;
      }
  
      class AssemblyTypesReflection
      {
          static void Main(string[] args)
          {
              object obj = new Class1() { Name = "John" } ;
  
              Assembly assembly = Assembly.GetExecutingAssembly();
              var AsmClass1 = (from i in assembly.GetTypes() where i.Name == "Class1" select i).FirstOrDefault();
  
  
              var list = SomeMethod&lt;AsmClass1&gt;((AsmClass1)obj); //Here it fails
          }
  
          static List&lt;T&gt; SomeMethod&lt;T&gt;(T obj) where T : new()
          {
              return new List&lt;T&gt; { obj };
          }
      }
  }
  </code></pre>
  
  <p>This is a demo taken out of a bigger context.</p>