title: Is there a way to get typeof Func<T, bool>?
body: <p><strong>Short version :</strong></p>
  
  <p>We can get the typeof <code>Func&lt;T,T&gt;</code> using: </p>
  
  <pre><code>typeof(Func&lt;,&gt;) 
  </code></pre>
  
  <p>but what if I want to get the type of <code>Func&lt;T, bool&gt;</code>, what should I use, or is it possible to do? Clearly this doesn't compile :</p>
  
  <pre><code>typeof(Func&lt;, bool&gt;)
  </code></pre>
  
  <hr>
  
  <p><strong>Long version :</strong></p>
  
  <p>Consider the following scenario, I have two similar method and I want to get the second one (<code>Func&lt;T, int&gt;</code>) using Reflection:</p>
  
  <pre><code>public void Foo&lt;T&gt;(Func&lt;T, bool&gt; func) { }
  
  public void Foo&lt;T&gt;(Func&lt;T, int&gt; func) { }
  </code></pre>
  
  <p>I'm trying this:</p>
  
  <pre><code> var methodFoo = typeof (Program)
              .GetMethods()
              .FirstOrDefault(m =&gt; m.Name == "Foo" &amp;&amp;
                          m.GetParameters()[0]
                          .ParameterType
                          .GetGenericTypeDefinition() == typeof (Func&lt;,&gt;));
  </code></pre>
  
  <p>But since the generic type definition of <code>Func&lt;T, bool&gt;</code> and <code>Func&lt;T, int&gt;</code> are equal it gives me the first method. To fix this I can do the following:</p>
  
  <pre><code>var methodFoo = typeof (Program)
              .GetMethods()
              .FirstOrDefault(m =&gt; m.Name == "Foo" &amp;&amp;
                          m.GetParameters()[0]
                          .ParameterType
                          .GetGenericArguments()[1] == typeof(int));
  </code></pre>
  
  <p>Then I get the correct method but I do not like this way. And it seems like a overhead for more complex situations. What I want to do is get the type of <code>Func&lt;T,bool&gt;</code> like in my failed attempt above, then instead of using Linq I can use <a href="http://msdn.microsoft.com/en-us/library/5fed8f59(v=vs.110).aspx">this overload</a> of <code>GetMethod</code> and do something like the following:</p>
  
  <pre><code>var methodFoo = typeof (Program)
              .GetMethod("Foo", 
              BindingFlags.Public | BindingFlags.Instance,
              null, 
              new[] {typeof (Func&lt;, bool&gt;)}, // ERROR typeof(Func&lt;,&gt;) doesn't work either
              null);
  </code></pre>
  
  <p>Note: Ofcourse <code>Func&lt;T,T&gt;</code> is just an example, question is not specific to any type.</p>