title: Best way to handle null when writing equals operator
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/73713/how-do-i-check-for-nulls-in-an-operator-overload-without-infinite-recursion">How do I check for nulls in an &#39;==&#39; operator overload without infinite recursion?</a>  </p>
  </blockquote>
  
  
  
  <p>When I overload the == operator for objects I typically write something like this:</p>
  
  <pre><code>    public static bool operator ==(MyObject uq1, MyObject uq2) {
          if (((object)uq1 == null) || ((object)uq2 == null)) return false;
          return uq1.Field1 == uq2.Field1 &amp;&amp; uq1.Field2 == uq2.Field2;
      }
  </code></pre>
  
  <p>If you don't down-cast to object the function recurses into itself but I have to wonder if there isn't a better way?</p>