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