I have a parent class, and two child classes.
CODE
public abstract class IndustryClassification
{ public bool operator ==(IndustryClassification ic1, IndustryClassification ic2);
}
public class IndustryClassification1 :IndustryClassification
{}
public class IndustryClassification2 :IndustryClassification
{}
I want to override the == operator, but I can't mark the method virtual or abstract (get error "Modifier not allowed"). When I have the operator override defined in the base class, the base == operator is called because the object is saved in a base class type.
If i don't override it in the base class it still never calls the child == operator (I think it just compares the addresses, or some other default comparison?.)
CODE
var ic1 = new IndustryClassification1(x,y);
var ic2 = new IndustryClassification1(x,y);
IndustryClassification[] list;//with ic1 and ic2
....
if (list[0] == list[1])
{
areEqual = false;
}
How can i get this to call the child == operator? I shouldn't have to cast it before testing. Right?