This is by design. We recommend you use GridBorder.Empty instead of null. Generally, trying to use null directly, eventually runs into problems that can be avoided by using GridBorder.Empty.
Here is the code that defines the == and != operators in the GridBorder class. In particular, if either argument is null, the == returns false.
///
/// The basic == operator.
///
/// The left-hand side of the operator
/// The right-hand side of the operator
///
/// bool
///
public static bool operator==( GridBorder lhs, GridBorder rhs )
{
if ((object) lhs == null || (object) rhs == null)
return false;
return lhs.Equals(rhs);
}
///
/// The basic != operator
///
/// The left-hand side of the operator
/// The right-hand side of the operator
///
/// bool
///
public static bool operator!=( GridBorder lhs, GridBorder rhs )
{
if ((object) lhs == null || (object) rhs == null)
return false;
return !lhs.Equals(rhs);
}
But if you use the static GridBorder.Empty member to flag 'null's, this code works.
GridBorder border = GridBorder.Empty;
Console.WriteLine("Border == null? " + (border == GridBorder.Empty ));
Console.WriteLine("Border != null? " + (border != GridBorder.Empty ) );