Click to Rate and Give Feedback
MSDN
MSDN Library
Visual Studio 2008
Visual Studio
Common Type System
 Arrays
Collapse All/Expand All Collapse All
This page is specific to
Microsoft Visual Studio 2008/.NET Framework 3.5

Other versions are also available for the following:
.NET Framework Developer's Guide
Arrays in the Common Type System

An array type is defined by specifying the element type of the array, the rank (number of dimensions) of the array, and the upper and lower bounds of each dimension of the array. All these are included in any signature of an array type, although they might be marked as dynamically (rather than statically) supplied. Exact array types are created automatically by the runtime as they are required, and no separate definition of the array type is needed. Arrays of a given type can only hold elements of that type. For more information on the type of a value, see the section "Values and Objects" in Common Type System Overview.

Values of an array type are objects. Array objects are defined as a series of locations where values of the array element type are stored. The number of repeated values is determined by the rank and bounds of the array.

Array types inherit from the type System..::.Array. This class represents all arrays regardless of the type of their elements or their rank. The operations defined on arrays are: allocating an array based on size and lower bound information; indexing an array to read and write a value; computing the address of an element of an array (a managed pointer); and querying for the rank, bounds, and total number of values stored in an array.

Arrays of one dimension with a zero lower bound for their elements (sometimes called vectors) have a type based on the type of the elements in the array, regardless of the upper bound. Arrays with more than one dimension, or with one dimension but a nonzero lower bound, have the same type if they have the same element type and rank, regardless of the lower bound on the array. Zero-dimensional arrays are not supported.

Reference

Other Resources

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Getting Data from DataGrid      austinramsay ... Hekmatullah   |   Edit   |   Show History
Say you had 7 indexes.

Example:
WRONG:

for(int x = 0; x <= 7; ++x)
{
Console.WriteLine(days[x]);
}

RIGHT:

for(int x = 0; x < 7; ++x)
{
Console.WriteLine(days[x]);
}



re austinramsay's comment      Thomas Lee   |   Edit   |   Show History
Not sure what example you are referring to?

Is this comment appropriate for this page?
Tags What's this?: Add a tag
Flag as ContentBug
re re austinramsay's comment      TryingToLearnC   |   Edit   |   Show History
I see what Austin is saying and it helped me debug some code. If you allocate an array with 50 occurrences, you cannot address occurrence 50 because there is no occurrence 50. The occurrences are 0 to 49.

Coming from a mainframe COBOL world, this tip really helped me clear up an OutOfScope exception. Thanks!
Tags What's this?: Add a tag
Flag as ContentBug
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks | Privacy Statement | Site Feedback
Page view tracker