- using System.IO;
- using System;
- class MethodOverloading
- {
- private static void Main(string[] args)
- {
- Console.WriteLine("Signature Addition_int_int for 10+20: {0}", Addition(10, 20));
- Console.WriteLine("Signature Addition_int_int_int for 10+20+30: {0}", Addition(10, 20, 30));
- Console.WriteLine("Signature Addition_int_float for 10+20.0f: {0}", Addition(10, 20.3f));
- Console.WriteLine("Signature Addition_float_int for 10.5f+20: {0}", Addition(10.5f, 20));
- Console.WriteLine("Signature Addition_float_float for 10.5f+20.3f: {0}", Addition(10.5f, 20.3f));
- }
- static int Addition(int x, int y)
- {
- return x + y;
- }
- static int Addition(int x, int y, int z)
- {
- return x + y + z;
- }
- static float Addition(int x, float y)
- {
- return x + y;
- }
- static float Addition(float x, int y)
- {
- return x + y;
- }
- static float Addition(float x, float y)
- {
- return x + y;
- }
- }
Output
Signature Addition_int_int for 10+20: 30
Signature Addition_int_int_int for 10+20+30: 60
Signature Addition_int_float for 10+20.0f: 30.3
Signature Addition_float_int for 10.5f+20: 30.5
Signature Addition_float_float for 10.5f+20.3f: 30.8