title: How to dispatch C# generic method call into specialized method calls
body: <p>I have the following C# class:</p>
  <pre><code>public class MyType&lt;T&gt;
  {
     public void TryParse(string p_value)
     {
        T value ;
  
        Parser.TryParse(p_value, out value);
  
        // Do something with value
     }
  }
  </code></pre>
  <p>The point is to call the right Parser.TryParse method, depending on the generic type T.</p>
  <p>This uses the following static class:</p>
  <pre><code>static public class Parser
  {
     static public void TryParse(string p_intput, out object p_output)
     {
        // Do something and return the right value
     }
  
     static public void TryParse(string p_intput, out double p_output)
     {
        // Do something and return the right value
     }
  
     static public void TryParse(string p_intput, out int p_output)
     {
        // Do something and return the right value
     }
  }
  </code></pre>
  <p>I expected this to work: In the worst case, the &quot;object&quot; TryParse would be called. Instead, I have two compilation errors:</p>
  <ul>
  <li>CS1502: The best overloaded method match for 'Parser.TryParse(string, out object)' has some invalid arguments</li>
  <li>CS1503: Argument 2: cannot convert from 'out T' to 'out object'</li>
  </ul>
  <p><b>Question 1:</b> I don't understand why this doesn't work: I can be naive, but aren't all C# objects supposed to derive from &quot;object&quot; ? <b>Why T cannot be converted to object?</b></p>
  <p><b>Question 2:</b> <b>How can I dispatch a method with generic type T into the right non-generic methods</b> (i.e. <code>MyType&lt;T&gt;.TryParse</code> calling the right <code>Parser.TryParse</code> according to the right type of T) ?</p>
  <h2>Note</h2>
  <p>The question was edited to reflect the original question intent (as written in the title: <i>How to dispatch C# generic method call into specialized method calls</i>)</p>