title: How do I make the type of a generic delegate in C#/.NET 4?
body: <p>I can make the type of a delegate at runtime from a list of parameter System.Type, thanks to a answer to a question here.</p>
  
  <p>But how do I do this when one of the parameters is a generic parameter, say it represents something like the following?</p>
  
  <pre><code>    delegate t ScanFun&lt;t&gt;();
  </code></pre>
  
  <p>I want a System.Type which represents a generic delegate so I can call Type.MakeGenericType method with the type for the generic parameter t. However, I can't even find a way to find out what the type of that looks like.</p>
  
  <p>The use is in a code analysis tool. This is the code I have which works with known types:</p>
  
  <pre><code>System.Type[] parms = new Type[f.sig.Parms.list.Length + 1];
  specs[0] = f.sig.ReturnType.Type;
  for (int i = 0; i &lt; f.sig.Parms.list.Length; i++)
      specs[i + 1] = f.sig.Parms.list[i].Type;
  for (int i = 0; i &lt; parmTypes_.Length; i++)
  {
      if (f.sig.Generic.List.Contains(specs[i].Name))
      {
          /// TODO: Make generic parameter Type here
          goto done;
      }
      parms[i] = f.Parent.findType(specs[i]);
      done: ;
  }
  var dtype = System.Linq.Expressions.Expression.GetDelegateType(parms);
  </code></pre>