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;
}
广告
数据结构
网络
RDBMS
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP