I have seen on the MSDN site that the == operator will return true if both is value type operands are equal.
To fully understand that I have declared the following structs (which to my knowledge are considered value types in C#), and used the == operator, but for some reason I do not understand, I get the following compilation errors.
Does anyone have any idea why the compiler shows these errors, even though p1 and p2 are clearly equal??
struct Point {
int m_X;
int m_Y;
}
Point p1 = new Point(10, 15);
Point p2 = new Point(10, 15);
Point p3 = p2;
bool equals = (p1 == p2); // Compile Error
bool equals = (p2 == p3); // Compile Error
bool equals = p1.Equals(p3);
bool equals = p1.Equals(p2);
Thanks!