C# 中的静态绑定是什么?
在编译期间将函数链接到对象的操作称为静态绑定。C# 提供了两种技术来实现静态多态:函数重载和运算符重载。
在函数重载中,可以在相同作用域中为同一函数名拥有多个定义。
示例
void print(int i) {
Console.WriteLine("Printing int: {0}", i );
}
void print(double f) {
Console.WriteLine("Printing float: {0}" , f);
}重载运算符是具有特殊名称的函数。关键词 operator 后接定义的运算符符号。
示例
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;
}
广告
数据结构
网络
RDBMS
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP