title: Infer generic type with two generic type parameters
body: <p>I have the following method</p>
  
  <pre><code>public bool HasTypeAttribute&lt;TAttribute, TType&gt;(TType obj)
  {
      return typeof(TType).GetCustomAttribute&lt;TAttribute&gt;() != null;
  }
  </code></pre>
  
  <p>and I want to be able to use it like this:</p>
  
  <pre><code>MyClass instance = new MyClass();
  
  TypeHelper.HasTypeAttribute&lt;SerializableAttribute&gt;(instance);
  </code></pre>
  
  <p>but I can't get it working because of the</p>
  
  <blockquote>
    <p>incorrect number of type parameters</p>
  </blockquote>
  
  <p>so that I need to call</p>
  
  <pre><code>TypeHelper.HasTypeAttribute&lt;SerializableAttribute, MyClass&gt;(instance);
  </code></pre>
  
  <p>which certainly makes sense, but why can the compiler not infer the type of the passed object? Because if the method looked like this:</p>
  
  <pre><code>public void Demo&lt;T&gt;(T obj)
  {
  }
  </code></pre>
  
  <p>the compiler would certainly be able to infer the type, so that I can write</p>
  
  <pre><code>Foo.Demo(new Bar());
  </code></pre>
  
  <p>instead of</p>
  
  <pre><code>Foo.Demo&lt;Bar&gt;(new Bar());
  </code></pre>
  
  <p>So, is there a way to make type inference work in this case? Is it a design flaw by me or can I achieve what I want? Reordering the parameters doesn't help too...</p>