The FunWithMethods application is located under the Chapter 4 subdirectory.
Understanding Member Overloading
Like other modern object-oriented languages, C# allows a method to be overloaded. Simply put,
when you define a set of identically named members that differ by the number (or type) of parame-
ters, the member in question is said to be overloaded. To check this out firsthand, create a new
Console Application project named MethodOverloading.
To understand why overloading is so useful, consider life as a Visual Basic 6.0 developer.
Assume you are using VB6 to build a set of methods that return the sum of various incoming types
(Integers, Doubles, and so on). Given that VB6 does not support method overloading, you would be
required to define a unique set of methods that essentially do the same thing (return the sum of the
arguments):
Do'stlaringiz bilan baham: