1 usingSystem;2 usingSystem.Collections.Generic;3 usingSystem.Linq;4 usingSystem.Text;5 usingSystem.Threading.Tasks;6 7 namespaceConsoleApplication78 {9 class ProgramTen { One Static voidMain (string[] args) A { - //Add integers - intA =1; the intb =3; - intsum =Test (A, b); -Console.WriteLine ("integer addition: {0}+{1}={2}", A, b, sum); - Console.WriteLine (); + //Add real numbers - Doublec =2.5; + DoubleD =5.2; A DoubleSUM1 =Test (c, D); atConsole.WriteLine ("sum of real numbers: {0}+{1}={2}", C, D, sum1); - Console.WriteLine (); - //real numbers plus integers - DoubleE =3.5; - intf =6; - Doublesum2 =Test (E, f); inConsole.WriteLine ("real number plus integer: {0}+{1}={2}", E, F, sum2); - Console.WriteLine (); to //integer plus real number + intg =8; - Doubleh =9.9; the DoubleSUM3 =Test (g, h); *Console.WriteLine ("integer plus real number: {0}+{1}={2}", G, H, sum3); $ Console.WriteLine ();Panax Notoginseng - Console.readkey (); the } + A Static intTest (intAintb) the { + intsum = a +b; - returnsum; $ } $ Static DoubleTest (DoubleADoubleb) - { - Doublesum = a +b; the returnsum; - }Wuyi Static DoubleTest (DoubleAintb) the { - Doublesum = a +b; Wu returnsum; - } About Static DoubleTest (intADoubleb) $ { - Doublesum = a +b; - returnsum; - } A } +}
Writes 4 methods of the same name, implements two integers, two real numbers, a real number, an integer, and an integer sum of a real number. Call these 4 methods in the keynote function to calculate the related values. (Overloading of methods)