码迷,mamicode.com
首页 > Windows程序 > 详细

C#基础之方法的重载

时间:2020-05-28 21:54:37      阅读:91      评论:0      收藏:0      [点我收藏+]

标签:out   str   需要   ble   bsp   修饰符   div   签名   返回   

在C#语言中,方法的重载作用非常大,但是使用重载需要注意方法的签名,必须有一种要不一样,具体指的是:

1、方法的返回值类型

2、方法的形参类型

3、形参类型的顺序

4、形参的个数

4、泛型的类型<string>

5、形参的修饰符如:out

 1 class Program
 2     {
 3         static void Main(string[] args)
 4         {
 5             
 6             Console.WriteLine(Student.Age(2,4.0));
 7         }
 8         static class Student
 9         {
10             public static double Age(double a, double b) 
11             {
12                 return 3.14 * a * b;
13             }
14             public static double Age(int a) 
15             {
16                 return 3.14 * a;
17             }
18             public static double Age(int a, double b)
19             {
20                 return a * b;
21             }
22             public static int Age(int a,int b,int h) 
23             {
24                 return a * b * h;
25             }
26         }
27     }

 

C#基础之方法的重载

标签:out   str   需要   ble   bsp   修饰符   div   签名   返回   

原文地址:https://www.cnblogs.com/zxbls/p/12983917.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!