What is early binding in C#?

CsharpProgrammingServer Side Programming

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

Let us learn about Function Overloading with an example −

You can have multiple definitions for the same function name in the same scope. The definition of the function must differ from each other by the types and/or the number of arguments in the argument list. You cannot overload function declarations that differ only by return type.

The following is the complete example −


 Live Demo

using System;

namespace PolymorphismApplication {
   class Printdata {
      void print(int i) {
         Console.WriteLine("Printing int: {0}", i );

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

      void print(string s) {
         Console.WriteLine("Printing string: {0}", s);

      static void Main(string[] args) {
         Printdata p = new Printdata();

         // Call print to print integer

         // Call print to print float

         // Call print to print string
         p.print("Hello C++");


Printing int: 5
Printing float: 500.263
Printing string: Hello C++
Updated on 20-Jun-2020 13:18:04