Exemple #1
0
        public static AddClasss1 operator -(AddClasss1 op1)
        {
            AddClasss1 returnVal = new AddClasss1();

            returnVal.val = -op1.val;
            return(returnVal);
        }
Exemple #2
0
        public static AddClasss1 operator +(AddClasss1 op1, AddClasss1 op2)
        {
            AddClasss1 returnVal = new AddClasss1();

            returnVal.val = op1.val + op2.val;
            return(returnVal);
        }
Exemple #3
0
        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);
        }