C#中的重载
重载在C#中有两种类型。
功能重载
在同一个作用域中,可以为同一个函数名具有多个定义。函数的定义必须在参数列表中的参数类型和/或数量上彼此不同。
让我们看一个例子-
public static int mulDisplay(int one, int two) { }
public static int mulDisplay(int one, int two, int three) { }
public static int mulDisplay(int one, int two, int three, int four) { }运算符重载
重载运算符是具有特殊名称的函数。关键字运算符后跟要定义的运算符的符号。
public static Box operator+ (Box b, Box c) {
Box box = new Box();
box.length = b.length + c.length;
box.breadth = b.breadth + c.breadth;
box.height = b.height + c.height;
return box;
}热门推荐
6 保研的祝福语简短
10 年轻20岁祝福语简短
11 朋友结婚祝福语信息简短
12 女孩婚礼贺卡祝福语简短
13 30段点歌简短祝福语
14 虎年春节祝福语图文简短
15 写给后妈祝福语大全简短
16 简短回复生日祝福语
17 校长送毕业祝福语简短
18 毕业立体贺卡祝福语简短