1 using System;
2 using System.Collections.Generic;
3 using System.Linq;
4 using System.Text;
5 using System.Threading.Tasks;
6
7 namespace ConsoleApplication7
8 {
9 class Program
10 {
11 static void Main(string[] args)
12 {
13 //整数相加
14 int a = 1;
15 int b = 3;
16 int sum = Test(a, b);
17 Console.WriteLine("整数相加:{0}+{1}={2}", a, b, sum);
18 Console.WriteLine();
19 //实数相加
20 double c = 2.5;
21 double d = 5.2;
22 double sum1 = Test(c, d);
23 Console.WriteLine("实数数相加:{0}+{1}={2}", c, d, sum1);
24 Console.WriteLine();
25 //实数加整数
26 double e = 3.5;
27 int f = 6;
28 double sum2 = Test(e, f);
29 Console.WriteLine("实数加整数:{0}+{1}={2}", e, f, sum2);
30 Console.WriteLine();
31 //整数加实数
32 int g = 8;
33 double h = 9.9;
34 double sum3 = Test(g, h);
35 Console.WriteLine("整数加实数:{0}+{1}={2}", g, h, sum3);
36 Console.WriteLine();
37
38 Console.ReadKey();
39 }
40
41 static int Test(int a, int b)
42 {
43 int sum = a + b;
44 return sum;
45 }
46 static double Test(double a, double b)
47 {
48 double sum = a + b;
49 return sum;
50 }
51 static double Test(double a, int b)
52 {
53 double sum = a + b;
54 return sum;
55 }
56 static double Test(int a, double b)
57 {
58 double sum = a + b;
59 return sum;
60 }
61 }
62 }