If reference type doesn't overload an equality operator ==
, then build-in equality operator on Object
will be used instead. Why isn't the same true for user-defined structs
:
struct A{ }
static void Main(string[] args)
{
A a = new A();
A a1 = new A();
bool equal= (a == a1); //error
}
Namely, doesn't ValueType
( from which all structs
derive ) also overload ==
operator?