Overloading Methods

A major topic in OOP is overloading methods, which lets you define the same method multiple times so that you can call them with different argument lists (a method's argument list is called its signature). C# not only supports method overloading, but revels in it. Most of the methods you'll find built into C# have several overloaded forms to make life easier for you—for example, you can call System.Console.WriteLine with a string, a float, an int, and so on, all because it's been overloaded to handle those types of arguments (it has 18 overloaded forms in all).

It's easy to overload a method; just define it multiple times, each time with a unique signature. You can see an example in ch03_12.cs, Listing 3.12, where we're working ...

Get Microsoft® Visual C#® .NET 2003 Kick Start now with the O’Reilly learning platform.

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