1 using System;
 2 using System.Collections.Generic;
 3 using System.Linq;
 4 using System.Text;
 5 
 6 namespace ConsoleApplication1
 7 {
 8     //定义类
 9     class Look
10     {
11         public static int Dev(int x, int y)
12         { return x / y; }
13         public static double Dev(double x, double y)  //重载.  可以使用同名的函数,但是返回值,或者参数必须不一样.
14         {
15             return x / y;
16         }
17     }
18 
19     class Program
20     {
21         static void Main(string[] args)
22         {
23             Console.WriteLine(Look.Dev(8,4));  //第一个, int型的
24             Console.WriteLine(Look.Dev(12.5,5.3));  // 第二个. 浮点型的
25         }
26     }
27 }

相关文章:

  • 2021-07-25
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-21
  • 2022-01-10
  • 2021-06-09
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-12-18
  • 2021-10-24
  • 2021-07-23
  • 2021-12-20
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案