With code as below
public class Task { string Name; public static bool operator ==(Task t1, Task t2) { return t1.Name = t2.Name && t1.GetType() == t2.GetType(); } } public class TaskA : Task { int aThing; public static bool operator ==(TaskA t1, TaskA t2) { return (Task)t1 == (Task)t2 && t1.GetType() == t2.GetType() && t1.aThing == t2.aThing; } } public class TaskB : Task
I am trying to make sure that the derived statement (TaskA. ==) is being called.
I get a compilation error when using the method here .
I think I can make it work correctly if the statement was not static, because I could then override the base class operator. Is it possible?
As soon as I get this, how would I compare the basic properties (I think casting to the type of the task [(Task) t1 == (Task) t2] will not work)?
source share