Arrays
It is possible to declare any type as an array of that type. Because an array is a modifier of another type, the basic Array class is never explicitly declared for a variable's type. The System.Array class that serves as the base for all arrays is defined such that it cannot be created, but must be inherited. As a result, to create an Integer array, a set of parentheses is added to the declaration of the variable. These parentheses indicate that the system should create an array of the type specified. The parentheses used in the declaration may be empty or may contain the size of the array. An array can be defined as having a single dimension using a single index, or as having multiple dimensions by using multiple indices.
All arrays and collections in .NET start with an index of zero. However, the way an array is declared in Visual Basic varies slightly from other .NET languages such as C#. Back when the first .NET version of Visual Basic was announced, it was also announced that arrays would always begin at 0 and that they would be defined based on the number of elements in the array. In other words, Visual Basic would work the same way as the other initial .NET languages. However, in older versions of Visual Basic, it is possible to specify that an array should start at 1 by default. This meant that a lot of existing code didn't define arrays the same way.
To resolve this issue, the engineers at Microsoft decided on a compromise: All arrays in .NET begin at 0, but when ...
Get Professional Visual Basic 2012 and .NET 4.5 Programming 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.