8.6. Passing an Array to a Method

To pass an array argument to a method, specify the name of the array without using parentheses. For example, if array hourlyTemperatures has been declared as

					Dim hourlyTemperatures As Integer() = New Integer(24) {}

the method call

DayData(hourlyTemperatures)

passes array hourlyTemperatures to method DayData.

Every array object “knows” its own upper bound (i.e., the value returned by the method GetUpperBound), so when you pass an array object to a method, you do not need to pass the upper bound of the array as a separate argument.

For a method to receive an array through a method call, the method’s parameter list must specify that an array will be received. For example, the method header for DayData might ...

Get Visual Basic 2005 for Programmers: Deitel Developer Series, Second Edition 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.