# Arrays

The array data type is a fundamental data type in most languages, including Visual Basic. An array is used to store a collection of similar data types or objects.

Many authors of programming books misuse the terms associated with arrays, so let’s begin by establishing the correct terminology. In fact, if you will indulge us, we would like to begin with a formal definition of the term array.

## Definition of Array

Let S^{1}, S^{2} ...,
S^{N} be finite sets, and let T be a data
type (such as Integer). Then an *array* of type T
is a function:

arr:S^{1}· S^{2}· ... · S^{N}T

where S^{1} ·
S^{2} · ...
· S^{N} is the Cartesian
product of the sets S^{1},
S^{2} ..., S^{N}.
(This is the set of all n-tuples whose coordinates come from the sets
S^{i}.)

For arrays in VB.NET (and the other languages that implement the
Common Language Runtime), the sets S^{i} must
have the form:

S^{i}={0,1,...,K^{i}}

In other words, each set S^{i} is a finite
set of consecutive integers starting with 0.

Each position in the Cartesian product is referred to as a
*coordinate* of the array. For each coordinate,
the integer K^{i} is called the upper bound
of the coordinate. The lower bound is 0 for all arrays in VB.NET.

## Dimension of an Array

The number N of coordinates in the domain of
the function *arr* is called the
*dimension* (or sometimes
*rank*) of the array. Thus, every array has a
dimension (note the singular); it is *not* correct
to refer to the dimension*s* of an array (note the
plural). An array of dimension 1 is called a
*one-dimensional array*, an array of dimension ...

Get *VB.NET Language in a Nutshell, Second Edition* now with O’Reilly online learning.

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