June 2006
Intermediate to advanced
1344 pages
42h 52m
English
Overloaded methods are often used to perform similar operations on different types of data. To motivate the concepte of generic methods, let’s begin with an example (Fig. 25.1) that contains three overloaded PrintArray methods (lines 19–25, 28–34 and 37–43). These methods display the elements of an Integer array, a Double array and a Char array, respectively. In Section 25.3, we reimplement this program more concisely and elegantly using a single generic method.
1 ' Fig. 25.1: OverloadedMethods.vb 2 ' Using overloaded methods to print arrays of different types. 3 Module OverloadedMethods 4 Sub Main() 5 ' create arrays of Integer, Double ... |
Read now
Unlock full access