title: Counterpart to anonymous interface implementations in C#
body: <p>I'm working on translating some code from Java to C# but am having some trouble, maybe someone out there can help?</p>
  
  <p>I have problems trying to replicate anonymous interface implementations that are widely used in Java, but have no idea how to.</p>
  
  <p>An example is:</p>
  
  <pre><code>List&lt;DATA&gt; queue1 = new ArrayList&lt;DATA&gt;(dataSet);
              // Sort by distance to the first promoted data
              Collections.sort(queue1, new Comparator&lt;DATA&gt;() {
                  @Override
                  public int compare(DATA data1, DATA data2) {
                      double distance1 = distanceFunction.calculate(data1, promoted.first);
                      double distance2 = distanceFunction.calculate(data2, promoted.first);
                      return Double.compare(distance1, distance2);
                  }
              });
  </code></pre>