publicclassComplex{publicstaticComplexoperator+(Complexc1,Complexc2){returnnewComplex(c1.real+c2.real,c1.imaginary+c2.imaginary);}}classTest{staticvoidMain(){Complexnum1=newComplex(2,3);Complexnum2=newComplex(3,4);// Add two Complex objects (num1 and num2) through the// overloaded plus operator:Complexsum=num1+num2;}}/*
* First complex number: 2 + 3i
* Second complex number: 3 + 4i
* The sum of the two numbers: 5 + 7i
*/
publicclassMyObject{// Implicit conversion from MyObject to string. Maps true to // "MyObject.Truthy" and false to "MyObject.Falsy"publicstaticimplicitoperatorstring(MyObjectx){returnMyObject.value.ToString();}// Explicit conversion from MyObject to int.publicstaticexplicitoperatorint(MyObjectx){returnMyObject.value;}}classTest{staticvoidMain(){MyObjectobj=newMyObject(5);Console.WriteLine(obj);// implicit conversion to stringConsole.WriteLine((int)obj);// explicit conversion to int}}/*
* 5
* 5
*/