title: C# object is not null but (myObject != null) still return false
body: <p>I need to do a comparaison between an object and NULL. When the object is not NULL I fill it with some data.</p>
  
  <p>Here is the code :</p>
  
  <pre><code> if (region != null)
   {
    ....
   }
  </code></pre>
  
  <p>This is working but when looping and looping sometime the region object is NOT null (I can see data inside it in debug mode). In step-by-step when debugging, it doesn't go inside the IF statement... When I do a Quick Watch with these following expression : I see the (region == null) return false, AND (region != null) return false too... <strong>why and how?</strong></p>
  
  <p><strong>Update</strong></p>
  
  <p>Someone point out that the object was == and != overloaded:</p>
  
  <pre><code>    public static bool operator ==(Region r1, Region r2)
      {
          if (object.ReferenceEquals(r1, null))
          {
              return false;
          }
          if (object.ReferenceEquals(r2, null))
          {
              return false;
          }
  
          return (r1.Cmr.CompareTo(r2.Cmr) == 0 &amp;&amp; r1.Id == r2.Id);
      }
  
  
      public static bool operator !=(Region r1, Region r2)
      {
          if (object.ReferenceEquals(r1, null))
          {
              return false;
          }
          if (object.ReferenceEquals(r2, null))
          {
              return false;
          }
          return (r1.Cmr.CompareTo(r2.Cmr) != 0 || r1.Id != r2.Id);
      }
  </code></pre>