title: Generic method with Action<T> parameter
body: <p>So, I'm sure this has been answered somewhere out there before, but I couldn't find it anywhere. Hoping some generics guru can help.</p>
  
  <pre><code>public interface IAnimal{}
  public class Orangutan:IAnimal{}
  
  public void ValidateUsing&lt;T&gt;(Action&lt;T&gt; action) where T : IAnimal
  {
      Orangutan orangutan = new Orangutan();
      action(orangutan);  //Compile error 1
  
      //This doesn't work either:
      IAnimal animal = new Orangutan();
      action(animal);  //Compile error 2
  }
  </code></pre>
  
  <ol>
  <li>Argument type 'Orangutan' is not assignable to parameter type 'T'</li>
  <li>Argument type 'IAnimal' is not assignable to parameter type 'T'</li>
  </ol>
  
  <p><strong>Edit: Based on Yuriy and other's suggestions</strong>, I could do some casting such as:</p>
  
  <pre><code>public void ValidateUsing&lt;T&gt;(Action&lt;T&gt; action) where T : IAnimal
  {
      Orangutan orangutan = new Orangutan();
      action((T)(IAnimal)orangutan);
  
      //This doesn't work either:
      IAnimal animal = new Orangutan();
      action((T)animal);
  }
  </code></pre>
  
  <p>The thing I wanted to do was call the ValidateUsing method like this:</p>
  
  <pre><code>ValidateUsing(Foo);  
  </code></pre>
  
  <p>Unfortunately, if foo looks like this:</p>
  
  <pre><code>private void Foo(Orangutan obj)
  {
      //Do something
  }
  </code></pre>
  
  <p>I have to explicitly specify the type when I call ValidateUsing</p>
  
  <pre><code>ValidateUsing&lt;Orangutan&gt;(Foo);
  </code></pre>