Optional parameters and method overloading <p>I've come across a library method with three parameters, all with default values:</p> <pre><code>virtual M(bool b1 = false, string s1 = null, bool b2 = true) </code></pre> <p>Method <code>M</code> shouldn't have parameter <code>s1</code>, so I want to remove it, but I don't want to make a breaking change in the DLL. Clients can obviously ignore <code>s1</code>, but I don't want to leave it there because <code>M</code> can be overridden and parameter <code>s1</code> is misleading. So here was my attempt:</p> <pre><code>virtual M(bool b1 = false, bool b2 = true) [Obsolete] virtual M(bool b1, string s1, bool b2 = true) </code></pre> <p>I figured that since optional parameters are compiled into the call site, existing clients would carry on calling the method with three parameters, whereas new or recompiled clients not using <code>s1</code> would link to the method with two parameters.</p> <p>Each call to <code>M</code> resolves okay, except this one:</p> <pre><code>M(b2: false); </code></pre> <p>The compiler reports that the call is ambiguous between "M(bool, bool)" and "M(bool, string, bool)".</p> <p>Oddly, in the parameter info (Ctrl+Shift+Space), Visual Studio is still showing the default values on the method with three parameters (despite cleaning and rebuilding, restarting VS, unloading and reloading projects).</p> <p>Obviously I can fix this by calling the new <code>M</code> something different, but I'm curious as to why it's not linking. Should it (and something's just out of step, as the out-of-date parameter info suggests), or does the compiler have a genuine issue with this?</p> <p>EDIT</p> <p>Like @p.s.w.g and as per @JonSkeet's suggestion, I can't reproduce this in fresh code, so I guess the question becomes: is there anything else I can try other than rebuilding, restarting, reloading to force VS to relink this?</p>