METHOD OVERLOADING IN C#.NET

Ankit Singh

Total Post:341

Points:2389
Posted by  Ankit Singh
C# 
 860  View(s)
Ratings:
Rate this:
we wnat method overloading in c# 
  1. aditya kumar Patel

    Post:254

    Points:1810
    Re: Method overloading in c#.net

    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

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!