title: Implicit (bool) and == operator override - handle if statements correctly
body: <p>I have a custom class with implement both the <code>==</code> and the <code>implicit</code> for boolean operator.</p>
  
  <p>Is this the correct way to handle all possible, if ==/!= statements and get the expected result?
  Like this:</p>
  
  <pre><code>public class Foo
  {
      public bool Result { get; set; }
  
      public static bool operator ==(bool @bool, Foo foo)
      {
          return Equals(foo, @bool);
      }
      public static bool operator !=(bool @bool, Foo foo)
      {
          return NotEquals(foo, @bool);
      }
      public static bool operator ==(Foo foo, bool @bool)
      {
          return Equals(foo, @bool);
      }
      public static bool operator !=(Foo foo, bool @bool)
      {
          return NotEquals(foo, @bool);
      }
      public static bool operator ==(Foo foo, Foo fooB)
      {
          return Equals(foo, fooB);
      }
      public static bool operator !=(Foo foo, Foo fooB)
      {
          return NotEquals(foo, fooB);
      }
      public static implicit operator bool(Foo foo)
      {
          try { return foo.Result; }
          catch { return false; }
      }
  
      private static bool Equals(Foo foo, Foo fooB)
      {
          if (object.Equals(foo, null))
          {
              if (object.Equals(fooB, null))
                  return true;
  
              return false;
          }
  
          if (object.Equals(fooB, null))
              return false;
  
          return foo.Result == fooB.Result;
      }
      private static bool NotEquals(Foo foo, Foo fooB)
      {
          if (object.Equals(foo, null))
          {
              if (object.Equals(fooB, null))
                  return false;
  
              return true;
          }
  
          if (object.Equals(fooB, null))
              return true;
  
          return fooB.Result != foo.Result;
      }
      private static bool Equals(Foo foo, bool @bool)
      {
          if (object.Equals(foo, null))
              return true;
  
          return @bool == foo.Result;
      }
      private static bool NotEquals(Foo foo, bool @bool)
      {
          if (object.Equals(foo, null))
              return false;
  
          return @bool != foo.Result;
      }
  
  }
  </code></pre>
  
  <p>I am especially wondering about the fact that its seems you really need to implement overloads for either </p>
  
  <pre><code>if (new Foo() != true)
  </code></pre>
  
  <p>and</p>
  
  <pre><code>if (true != new Foo())
  </code></pre>