title: c#: Extending functionality of an interface keeping it backward compatible
body: <p>I have an interface called <code>IEvaluator</code> as a part of library I have created.</p>
  
  <pre><code>public interface IEvaluator&lt;T&gt;
  {
      public bool Evaluate&lt;T&gt;(T key, T value);
  }
  </code></pre>
  
  <p>Earlier it used to evaluate whether key is equal to value or not. Now, I want to add support for more operators in it say less than, greater than etc keeping it backward compatible at the same time i.e. only those people who want extended support should update their code and not others. I know that .NET provides an similar interface called <code>IComparer&lt;T&gt;</code> but using that is not an option here.</p>
  
  <p>I tried few approached but non of them seems to work</p>
  
  <ul>
  <li><p>Put operator as default argument.</p>
  
  <pre><code>public interface IEvaluator&lt;T&gt;
  { 
      public bool Evaluate&lt;T&gt;(T key, T value, string operatorVal = "=");
  }
  </code></pre></li>
  <li><p>Add a new method in the interface and provide its implementation using extension methods.</p>
  
  <pre><code>public interface IEvaluator&lt;T&gt;
  { 
      public bool Evaluate&lt;T&gt;(T key, T value);
      public bool Evaluate&lt;T&gt;(T key, T value, string operatorVal = "=");
  }
  
  public static class ExtensionMethods
  {
      public static bool Evaluate&lt;T&gt;(this.IEvaluator evaluator, T key, T value, string operatorVal = "=")
      {
          return evaluator.Evaluate(key, values);
      }
  }
  </code></pre></li>
  </ul>
  
  <p>In both the cases, I'm getting that the function with default argument is not implement. What is the correct way of doing such kind of enhancement?</p>