public class Apple{
public decimal Weight{get;set;}
public static decimal operator +(Apple a1, Apple a2)
{
return a1.Weight-a2.Weight;
}
}
Apple a=new Apple{Weight=200};
Apple b=new Apple{Weight=300};
Console.Write(b-a);
C#运算符重载
最新推荐文章于 2021-11-02 11:47:16 发布