public static AddClasss1 operator -(AddClasss1 op1) { AddClasss1 returnVal = new AddClasss1(); returnVal.val = -op1.val; return(returnVal); }
public static AddClasss1 operator +(AddClasss1 op1, AddClasss1 op2) { AddClasss1 returnVal = new AddClasss1(); returnVal.val = op1.val + op2.val; return(returnVal); }
static void Main(string[] args) { AddClasss1 op1 = new AddClasss1(); op1.val = 5; AddClasss1 op2 = new AddClasss1(); op2.val = 5; AddClasss1 op3 = op1 + op2; Console.WriteLine(op3); Console.WriteLine(-op3); }