title: How to make a .Net generic method behave differently for value types and reference types?
body: <p>I have two implementations of a method, one for value types and another for reference types:</p>
  
  <pre><code>public static Result&lt;T&gt; ImplRef(T arg) where T : class {...}
  public static Result&lt;T&gt; ImplVal(T arg) where T : struct {...}
  </code></pre>
  
  <p>I want to write a method which calls the correct implementation like this</p>
  
  <pre><code>public static Result&lt;T&gt; Generic(T arg) {
      if (typeOf(T).IsValueType)
           return ImplVal(arg);
      else
           return ImplRef(arg);
  }
  </code></pre>
  
  <p>Obviously, the above implementation doesn't compile. How can I do this with minimum of reflection?</p>