Overloading Methods and Constructors

When a method is overloaded, a component contains two methods with exactly the same name. Many methods in .NET Framework are overloaded, including String.Replace(), Random.Next(), and Page.FindControl().

For example, here is a list of the three overloaded versions of the Random.Next() method:

Next() Returns a random number between 0 and 2,147,483,647.

Next(upperbound) Returns a number between 0 and the upper bound.

Next(lowerbound, upperbound) Returns a number between the lower bound and the upper bound.

Because all three methods do the same thing—they all return a random number—it makes sense to overload the Next() method. The methods differ only in their signatures. A method signature consists of ...

Get ASP.NET 4 Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.