How to define the operator ==

后端 未结 4 541
执笔经年
执笔经年 2021-01-22 21:37

Given the class as follows,

public class Number
{
  public int X { get; set; }
  public int Y { get; set; }
}

How to define an overload operato

4条回答
  •  栀梦
    栀梦 (楼主)
    2021-01-22 21:55

    overload the operator yourself:

    public static bool operator ==(Number a, Number b)
    {
        // do stuff
        return true/false;
    }
    

提交回复
热议问题