Method overloading in c#.net

Total Post:341

Points:2389
C# 
 1063  View(s)
Ratings:
Rate this:
we wnat method overloading in c# 
  1. Post:279

    Points:1987
    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 Apr-10-2018 05:12:11 AM

Answer

NEWSLETTER

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