//方法重载,简单说就是函数或者方法有相同的名称,但是参数列表不相同; //这样的同名不同参数的函数或者方法之间,我们称之为重载函数或者方法;
//main函数中调用的时候,虽然方法名字相同,但根据参数表可以自动调用对应的 函数。
public static void M(int n1, int n2)
{
int result = n1 + n2;
}
//public static int M(int a1, int a2)
//{
// return a1 + a2;
//}
public static double M(double d1, double d2)
{
return d1 + d2;
}
public static void M(int n1, int n2, int n3)
{
int result = n1 + n2 + n3;
}
public static string M(string s1, string s2)
{
return s1 + s2;
}
35.C#--方法的重载
原创
©著作权归作者所有:来自51CTO博客作者初禾的原创作品,请联系作者获取转载授权,否则将追究法律责任
下一篇:36.C#--方法的递归
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
C++入门-命名空间、引用、函数重载
C++入门知识,包括命名空间,引用,函数重载等。
命名空间 函数重载 传引用 C++ -
C#方法的重载
问:什么是方法的重载?答:方法的名称相同,但是参数不同。参数不同,分为2种情况:
java 算法 开发语言 方法重载 方法名 -
【C#视频】方法重载、函数重载、传值
方法的参数表必须
构造函数 初值 数组 -
c# 重载实例
☆C#的运算符定义只有四
c# string microsoft object equals -
【C#视频】探究C#中的方法重载、函数重载和传值方式
C#作为一门现代的编程语言,提供了丰富的特性来增强代码的可读性和可维护性。其中,方法重载、函数重载以及
c# 算法 数据结构 函数重载 参数类型 -
C#重载关闭按钮
老是记不住override关键字。。因此也就不会重载函数。。。 记个例子。。。体关闭事件的
c# constructor class string 编程