// The parameter of the binary operator must be of the include type.
// A parameter must be a class
//-============================================== ========================
Using system;
Using system. Collections. Generic;
Using system. text;
Namespace mystudy
...{
Class Program
...{
Static void main (string [] ARGs)
...{
Result R1 = new result (10, 20 );
Test r2 = new test ();
Result r = R1 + R2;
Console. writeline (R. I );
}
}
Public class result
...{
Public static result operator + (result C1, test C2) // The parameter must be a class
...{
Result T1 = new result (0, 0 );
T1. I = c1. I + c2. I;
T1.j = c1.j + c2.j;
Return T1;
}
Public int I, J;
Public result (int I, Int J)
...{
This. I = I;
This. j = J;
}
}
Public class test
...{
Public int I = 100, j = 200;
}
}
In addition
1. When the comparison operator number is reloaded, it must be reloaded in pairs (= ,! =) (>,<) (>=, <=)
2. The comparison operator must return a value of the bool type.