What is static binding in C#?

CsharpProgrammingServer Side Programming

The linking of a function with an object during compile time is called static binding. C# provides two techniques to implement static polymorphism: Function overloading and Operator overloading.

In Function Overloading, you can have multiple definitions for the same function name in the same scope.

Example

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 followed by the symbol for the operator being defineD.

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;
}
raja
Published on 16-Aug-2018 08:59:34
Advertisements