Arrays

An array is a collection of related types, and there are several ways to declare an array in MSIL. The underlying type of any array is always System.Array. With an array reference, you can call the methods and access the properties of System.Array.

Table 14-6 lists different syntax for defining an array.

Table 14-6. Syntax for defining arrays

Syntax

Description

type [] arrayname

Declares a one-dimensional array of an undetermined size.

type [,] arrayname

Declares a two-dimensional array of an undetermined size. You can expand the array beyond two dimensions by extending the comma-delimited list. For example, "type [,,,] arrayname"defines a four-dimensional array.

type [n] arrayname

Declares an array of n size.

type [m,n] arrayname

Declares an array ...

Get Programming Microsoft® Visual C#® 2008: The Language 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.