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) { }运算符重载
重载的运算符是具有特殊名称的函数。keyword 运算符后跟要定义的运算符符号。
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;
}
广告
数据结构
网络
RDBMS
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP