/ Published in: C#
To accomplish Method Overloading, a developer can define two or more methods with the same name. Each method will take a different set of parameters. The parameter combination or signature, is what the compiler uses to determine which method to use.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
using System; namespace MethodOverloading { class Program { static void Main(string[] args) { MethodOverloadPlay(10, 3); Console.WriteLine("+++++"); MethodOverloadPlay(5, 5, 6); Console.WriteLine("+++++"); MethodOverloadPlay("SP"); Console.ReadLine(); } static void MethodOverloadPlay(int number1, int number2) { int result = number1 + number2; Console.WriteLine(result); } static void MethodOverloadPlay(int number1, int number2, int number3) { int result = number1 + number2 + number3; Console.WriteLine(result); } static void MethodOverloadPlay(string string1) { Console.WriteLine("Breaking Benjamin & Sick Puppies Rock!"); } } }