✅ Question about inheritance c# [SOLVED]
So, the project I’m working on has these classes with inheritance:
CartoPoint : BasePoint -- BasePoint : Point3D -- Point3D : Point2D -- Point2D : IClonable
CartoPoint and BasePoint are our own classes, while Point3D and Point2D are from Eyeshot.
Point2D's Equals:
public bool Equals(Point2D other);
public override bool Equals(object obj);
Point3D's Equals:
public override bool Equals(object obj);
public bool Equals(Point3D other);
BasePoints' Equal:
public override bool Equals(object obj)
(compares yxz + other atts)
CartoPoint's Equal:
public override bool Equals(object obj)
(compares xyz + even more atts)
Okay so, with that context (see image1), when i do:
CartoPoint point1 = new CartoPoint(...)
point1.Equals((object)point1); //Uses CartoPoint's equals
point1.Equals(point1); //Uses Point3D's equals
Is there something I’m missing here? Shouldn’t both lines use CartoPoint's Equals, since it's overridden?
I found a post about deep dynamic dispatching, which might have something to do with this behavior, but ngl, I have no clue what’s going on
.
Any ideas?
CartoPoint : BasePoint -- BasePoint : Point3D -- Point3D : Point2D -- Point2D : IClonable
CartoPoint and BasePoint are our own classes, while Point3D and Point2D are from Eyeshot.
Point2D's Equals:
public bool Equals(Point2D other);
public override bool Equals(object obj);
Point3D's Equals:
public override bool Equals(object obj);
public bool Equals(Point3D other);
BasePoints' Equal:
public override bool Equals(object obj)
(compares yxz + other atts)
CartoPoint's Equal:
public override bool Equals(object obj)
(compares xyz + even more atts)
Okay so, with that context (see image1), when i do:
CartoPoint point1 = new CartoPoint(...)
point1.Equals((object)point1); //Uses CartoPoint's equals
point1.Equals(point1); //Uses Point3D's equals
Is there something I’m missing here? Shouldn’t both lines use CartoPoint's Equals, since it's overridden?
I found a post about deep dynamic dispatching, which might have something to do with this behavior, but ngl, I have no clue what’s going on
Any ideas?
