Home >Backend Development >C#.Net Tutorial >What is static binding in 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.
void print(int i) { Console.WriteLine("Printing int: {0}", i ); } void print(double f) { Console.WriteLine("Printing float: {0}" , f); }
Overloaded operators are functions with special names. The keyword operator IS is followed by the symbol used to define the operator for D.
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; }
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!