Method Overloading: is using the same method name with different type of parameters or different set of parameters
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace funoverloadingDemo
{
class Program
{
void add(int x, int y)
{
int z = x + y;
Console.WriteLine("addtion is {0}", z);
}
void add(float x, float y)
{
float z = x + y;
Console.WriteLine("addtion is {0}", z);
}
void add(int a, int b, int c)
{
int s = a + b + c;
Console.WriteLine("addtion is {0}", s);
}
static void Main(string[] args)
{
Program p1, p2, p3;
p1 = new Program();
p1.add(10, 20);
p1.add(10.5f, 20.5f);
p1.add(10, 20, 30);
Console.ReadLine();
}
}
}
Comments
Post a Comment