Home > DeveloperSection > Forums > Method overloading in c#.net
Ankit Singh

Total Post:341

Points:2389
Posted on    November-02-2015 9:51 PM

 .NET C# 
Ratings:


 1 Reply(s)
 310  View(s)
Rate this:
we wnat method overloading in c# 


aditya kumar Patel

Total Post:250

Points:1782
Posted on    November-02-2015 9:59 PM

Method Overloading is a feature that allows a class to have two or more methods having same name, if their argument lists are different.

using System;

using System.Collections.Generic;

using System.Linq;

using System.Net;

using System.Text;

using System.Threading;

namespace Forum

{

class Program

{

static void Main(string[] args)

{

// add tow numbers using plus method

Console.WriteLine("Add tow Numbers:" + OverLoading.Plus(10, 10));

// add three numbers using plus method

Console.WriteLine("Add three Numbers:"+ OverLoading.Plus(10, 10,10));

Console.ReadLine();

}

}

class OverLoading

{

public static int Plus(int number1, int number2)

{

return Plus(number1, number2, 0);

}

public static int Plus(int number1, int number2, int number3)

{

return number1 + number2 + number3;

}

}

}

 we create tow method for add number with different parameter . that is called method overloading.


Modified On Nov-02-2015 10:01:28 PM

Don't want to miss updates? Please click the below button!

Follow MindStick