title: MethodInfo Equality for Declaring Type
body: <p>I need to check equality between two MethodInfos. They are actually the exact same MethodInfo with the exception of the ReflectedType (that is, the DeclaringType is the same and the methods should actually have the same body). There are a number of ways of doing this, but I'm looking for the most efficient.</p>
  
  <p>Right now I have:</p>
  
  <pre><code>    public static bool AreMethodsEqualForDeclaringType(this MethodInfo first, MethodInfo second)
      {
          first = first.ReflectedType == first.DeclaringType ? first : first.DeclaringType.GetMethod(first.Name, first.GetParameters().Select(p =&gt; p.ParameterType).ToArray());
          second = second.ReflectedType == second.DeclaringType ? second : second.DeclaringType.GetMethod(second.Name, second.GetParameters().Select(p =&gt; p.ParameterType).ToArray());
          return first == second;
      }
  </code></pre>
  
  <p>This is kind of expensive, so I'm wondering if there's a better way...</p>
  
  <p>Should I be comparing the two method bodies instead? eg.</p>
  
  <pre><code>first.GetMethodBody() == second.GetMethodBody()
  </code></pre>
  
  <p>Thanks.</p>