What is method overloading in C#?

What is method overloading in C#?

In C#, method overloading occurs when one uses the same method name with different type of parameters or different set of parameters. It can also be said that creating multiple methods in a class with same name but different parameters and types is called as method overloading.

C# supports a lot of default or optional parameters. However, there is no facility to declare optional parameters as preferred by the user. Hence, there are times when the same method name must be used to facilitate different functions. In order to do that, the method name must then be set to different parameter. When this is used, it is known as method overloading.

One common example of method overloading is compile time polymorphism which is done at compile time.

Add new comment

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.