title: C# Generics How Can I get the type passed as an argument for a generic method with no object type as a parameter?
body: <p>I need a method to find the original type of an argument called for a generic method like this:</p>
  
  <pre><code>public GetGenericArgumentName&lt;T&gt;() where T : IFoo
  {
          StackFrame fr = new StackFrame(0, true);
          StackTrace st = new StackTrace(fr);
          var ga = fr.GetMethod().GetGenericArguments();
  
          foreach (var item in ga)
          {
              Console.WriteLine(item.Name);
          }
  }
  </code></pre>
  
  <p>But I couldn't get the original type at the caller.</p>
  
  <p>Let's say, I have to derived classes from IFoo</p>
  
  <pre><code>public class Foo : IFoo {}
  public class Foo2 : IFoo {}
  </code></pre>
  
  <p>If I call them with the following methods I expect these results:</p>
  
  <pre><code>/* 1 */ GetGenericArgumentName&lt;Foo&gt;()
  /* 2 */ GetGenericArgumentName&lt;Foo2&gt;()
  </code></pre>
  
  <p>For the first one, I expected Foo as result, and for the second Foo2.
  What am I missing?</p>