Home > Backend Development > C#.Net Tutorial > What is static binding in C#?

What is static binding in C#?

PHPz
Release: 2023-09-02 09:13:02
forward
1070 people have browsed it

C# 中的静态绑定是什么?

The linking of functions and objects during compilation is called static binding. C# provides two techniques for achieving static polymorphism: function overloading and operator overloading.

In function overloading, the same function name in the same scope can have multiple definitions.

Example
void print(int i) {
   Console.WriteLine("Printing int: {0}", i );
}

void print(double f) {
   Console.WriteLine("Printing float: {0}" , f);
}
Copy after login

Overloaded operators are functions with special names. The keyword operator IS is followed by the symbol used to define the operator for D.

Example

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;
}
Copy after login

The above is the detailed content of What is static binding in C#?. For more information, please follow other related articles on the PHP Chinese website!

source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template