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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.