Function Overloading Tutorial C# with Programming Example

function-overloading
In this chapter you will learn:

  • What is Function Overloading?
  • Function Overloading with Programming Example

Function Overloading

In function overloading, a function works differently based on parameters. A single function can have different nature based on number of parameters and types of parameters. For example, you have a function Sum() that accepts values as parameter and print their addition. You can write multiple function with name Sum() but the parameter signature must be different.

Programming Example

  • Output

    No Value Provided
    Sum of 5 and 4 is 9
    Sum of 9.3 and 8.6 is 17.9
    Hello World – is not a numeric value
    _

    Guidelines

    When you are doing method overloading, must remember following guidelines:

    1. Methods must be different based on their signature like number of parameters and types of parameters.
    2. There is no limit for method overloading. You can write multiple methods with same name but the signature must be different.

    Summary

    In this chapter you learned about Function Overloading in C#. In the next chapter you will learn about Operator Overloading in C# with programming example.


    Leave a Reply

    Your email address will not be published. Required fields are marked *