Quantcast
Channel: All About ASP.NET and ASP.NET Core 2 Hosting BLOG
Viewing all articles
Browse latest Browse all 427

ASP.NET Hosting - ASPHostPortal.com :: Easy Steps to Use Method Overloading in C# ASP.NET

$
0
0

If a class have multiple methods by same name but different parameters, it is known as Method Overloading.

string sum(int A)
string sum(int A, int B)

C# no need to use any keyword while overloading a method either in same class or in derived class.

While overloading methods, a rule to follow is the overloaded methods must differ either in number of arguments they take or the data type of at least one argument.

Example

using System;
namespace MethodOverloading
{
    class Class1
    {
        public int Sum(int A, int B)
        {
            return A + B;
        }
        public float Sum(int A, float B)
        {
            return A + B;
        }
    }
    class MainClass
    {
        static void Main()
        {
            Class1 obj = new Class1();
            Console.WriteLine(obj.Sum(20, 30));
            Console.WriteLine(obj.Sum(20, 15.70f));
            Console.Read();
        }
    }
}

Best ASP.NET Hosting Recommendation

ASPHostPortal.com provides its customers with Plesk Panel, one of the most popular and stable control panels for Windows hosting, as free. You could also see the latest .NET framework, a crazy amount of functionality as well as Large disk space, bandwidth, MSSQL databases and more. All those give people the convenience to build up a powerful site in Windows server. ASPHostPortal.com offers ASP.NET hosting starts from $1/month only. They also guarantees 30 days money back and guarantee 99.9% uptime. If you need a reliable affordable ASP.NET Hosting, ASPHostPortal.com should be your best choice.


Viewing all articles
Browse latest Browse all 427

Trending Articles