title: Testing delegates for equality
body: <p>I'm building a hierarchical collection class that orders magnetic resonance images spatially and arranges them into groupings based on the various acquisition parameters that were used to generate them.  The specific method used to perform the grouping is provided by the user of the class.  I've abstracted out the relevant features in the sample code below.  For the <code>IEquatable&lt;MyClass&gt;</code> implementation, I'd like to be able to compare the <code>_myHelperDelegate</code> attributes of two <code>MyClass</code> instances to determine if both delegates point to the same piece of code.  The <code>(_myHelperDelegate == other._myHelperDelegate)</code> clause in the if statement below is clearly the wrong way to go about doing this (it fails to compile, giving the error "Method name expected").  My question is, is there a way to compare two delegates to determine if they reference the same piece of code?  If so, how do you do that?</p>
  
  <pre><code>public class MyClass : IEquatable&lt;MyClass&gt;
  {
     public delegate object HelperDelegate(args);
     protected internal HelperDelegate _myHelperDelegate;
  
     public MyClass(HelperDelegate helper)
     {
        ...
        _myHelperDelegate = helper;
     }
  
     public bool Equals(MyClass other)
     {
        if (
            (_myHelperDelegate == other._myHelperDelegate) &amp;&amp;
            (... various other comparison criteria for equality of two class instances... )
           )
           return true;
        return false;
     }
  }
  </code></pre>