title: How can I specify default values for method parameters in c#7 tuples?
body: <p>In C#, you can define default parameters as described <a href="https://stackoverflow.com/q/3482528/1016343">here</a>. I was playing around with tuples and C#7 (using <a href="http://www.linqpad.net/" rel="nofollow noreferrer">LinqPad</a> with <code>Preferences -&gt; Queries -&gt; Use Roslyn assemblies</code> turned on) as follows:</p>
  <pre><code>void Main()
  {   
      var result=AddTuples((1, 2),  (3, 4));
      Console.WriteLine($&quot;Result is: {result}&quot;);
  }
  
  (int x, int y) AddTuples((int x, int y) a,  (int x, int y) b)
  {
      return (a.x + b.x,  a.y + b.y);
  }
  </code></pre>
  <p>This works fine, it shows the sum of a and b:</p>
  <blockquote>
  <p>Result is: (4, 6)</p>
  </blockquote>
  <p>Now I was trying to modify <code>AddTuples</code> to have default parameters, but somehow I couldn't figure out how. What I tried is something like:</p>
  <pre><code>(int x, int y) AddTuples2((int x, int y) a = (0, 0),  (int x, int y) b = (0, 0))
  {
      return (a.x + b.x,  a.y + b.y);
  }
  </code></pre>
  <p>But I am getting the error message:</p>
  <blockquote>
  <p>CS1736 Default parameter value for 'a' must be a compile-time constant</p>
  <p>CS1736 Default parameter value for 'b' must be a compile-time constant</p>
  </blockquote>
  <p>(try it online with <a href="https://dotnetfiddle.net/H2CdNG" rel="nofollow noreferrer">DotNetFiddle</a>)</p>
  <p>What am I doing wrong?</p>
  <hr />
  <h2>Update</h2>
  <p>Thank you for the great answers provided, I've learned a lot. Let me wrap up: To have default values for tuple parameters, there are 3 possible options:</p>
  <ol>
  <li>The old fashioned way: Overloading the method, provide defaults in method body. Disadvantage: If you have more than 2 tuples, overloading becomes cumbersome.</li>
  <li><a href="https://stackoverflow.com/a/41892450/1016343">Use nullable tuples</a>, provide defaults in method body.</li>
  <li><a href="https://stackoverflow.com/a/41892614/1016343">Use tuple's default values</a></li>
  <li><a href="https://stackoverflow.com/a/41892614/1016343">Use a <code>params</code> array</a> to allow more than 2 tuples in the method's parameters, provide defaults in method body</li>
  </ol>
  <p><strong>Note:</strong> Options 1., 2. and 4. allow to specify any desired default value, while option 3. is limited to the default values provided by the <code>default</code> keyword.</p>