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;
}热门推荐
10 退休祝福语简短独特老师
11 业主装修完成祝福语简短
12 成年礼简短的祝福语
13 给老师新年祝福语 简短
14 集体年会祝福语简短创意
15 开盘大吉的简短祝福语
16 对女儿生日祝福语简短
17 退休后祝福语简短护士
18 奶茶店新年祝福语简短