C# program to demonstrate method overloading based on types of arguments
All Answers
total answers (1)
Severity: 8192
Message: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated
Filename: libraries/Filtered_db.php
Line Number: 23
total answers (1)
Program:
The source code to demonstrate method overloading based on the type of arguments is given below. The given program is compiled and executed successfully on Microsoft Visual Studio.
Output:
Explanation:
In the above program, we created a class MethodOver, here we overloaded the sum() method based on the type of arguments to calculate the sum of given arguments.
Here, we created the three methods to calculate the sum of given arguments and return the result to the calling method.
Now look to the Main() method. Here we created the local variable result and then called each overloaded method one by one and printed the result on the console screen.