C# 类(5) 重载

 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 }
原文地址:https://www.cnblogs.com/mdnx/p/2677946.html