title: Disambiguate between two constructors, when two type parameters are the same
body: <p>Given </p>
  
  <pre><code>class Either&lt;A, B&gt; {
  
      public Either(A x) {}
      public Either(B x) {}
  }
  </code></pre>
  
  <p>How to disambiguate between the two constructors when the two type parameters are the same? </p>
  
  <p>For example, this line:</p>
  
  <pre><code>var e = new Either&lt;string, string&gt;("");
  </code></pre>
  
  <p>Fails with:</p>
  
  <blockquote>
    <p>The call is ambiguous between the following methods or properties: 'Program.Either.Either(A)' and 'Program.Either.Either(B)'</p>
  </blockquote>
  
  <p>I know if I had given the parameters different names (e.g. <code>A a</code> and <code>B b</code> instead of just <code>x</code>), I could use named parameters to disambiguate (e.g. <code>new Either&lt;string, string&gt;(a: "")</code>). But I'm interested in knowing how to solve this without changing the definition of <code>Either</code>.</p>
  
  <p>Edit:</p>
  
  <p>You <em>can</em> write a couple of smart constructors, but I'm interested in knowing if the <code>Either</code>'s constructors can be called directly without ambiguity. (Or if there are other "tricks" besides this one).</p>
  
  <pre><code>static Either&lt;A, B&gt; Left&lt;A, B&gt;(A x) {
      return new Either&lt;A, B&gt;(x);
  }
  
  static Either&lt;A, B&gt; Right&lt;A, B&gt;(B x) {
      return new Either&lt;A, B&gt;(x);
  }
  
  var e1 = Left&lt;string, string&gt;("");
  var e2 = Right&lt;string, string&gt;("");
  </code></pre>