title: Calling non-generic method from generic method in C#
body: <p>This is similar to this question <a href="https://stackoverflow.com/questions/62114504/call-overloaded-generic-method-from-generic-method">Call overloaded generic method from generic method</a> but it's not the same: in that case, the method returned <code>void</code>, while I need to return the generic type <code>T</code>, so the proposed solution does not work.</p>
  <p>I'm implementing a tuple-like class which has generic parameters and accessors for these parameters:</p>
  <pre><code>public class MyClass&lt;T1, T2&gt;
  {
      private readonly T1 _item1;
      private readonly T2 _item2;
  
      public MyClass(T1 item1, T2 item2)
      {
          _item1 = item1;
          _item2 = item2;
      }
  
      public T1 GetItem(T1 _) =&gt; _item1;
  
      public T2 GetItem(T2 _) =&gt; _item2;
  
      private T GetItem&lt;T&gt;(T x)
      {
          throw new ArgumentException();
          // return x;
      }
  
      public T Get&lt;T&gt;()
      {
          return GetItem(default(T));
      }
  }
  </code></pre>
  <p>I would like to use this class like this:</p>
  <pre><code>var obj = new MyClass&lt;int, string&gt;(1, &quot;hello&quot;);
  var a = obj.Get&lt;int&gt;();
  var b = obj.Get&lt;string&gt;();
  </code></pre>
  <p>But if I try this, the Generic <code>T GetItem&lt;T&gt;(T x)</code> is always called (the exception is thrown), and not the non-generic implementations.</p>
  <p>If I try to access the <code>GetItem</code> method directly, it works as intended:</p>
  <pre><code>var obj = new MyClass&lt;int, string&gt;(1, &quot;hello&quot;);
  var q = obj.GetItem(default(int));
  var w = obj.GetItem(default(string));
  </code></pre>
  <p><code>q</code> and <code>w</code> contain <code>1</code> and <code>hello</code> as expected.</p>
  <p>Is there a way for me to use this class as I want (using <code>obj.Get&lt;T&gt;</code>)? I want to avoid <code>Item1</code> <code>Item2</code> <code>Item3</code> getters.</p>