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 二胎祝福语简短霸气