Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
C-sharp language specification.2004.pdf
Скачиваний:
14
Добавлен:
23.08.2013
Размер:
2.55 Mб
Скачать

Chapter 19 Arrays

119. Arrays

2An array is a data structure that contains a number of variables which are accessed through computed

3indices. The variables contained in an array, also called the elements of the array, are all of the same type,

4and this type is called the element type of the array.

5An array has a rank which determines the number of indices associated with each array element. The rank of

6an array is also referred to as the dimensions of the array. An array with a rank of one is called a single-

7dimensional array. An array with a rank greater than one is called a multi-dimensional array. Specific sized

8multi-dimensional arrays are often referred to as two-dimensional arrays, three-dimensional arrays, and so

9on. Each dimension of an array has an associated length which is an integral number greater than or equal to

10zero. The dimension lengths are not part of the type of the array, but rather are established when an instance

11of the array type is created at run-time. The length of a dimension determines the valid range of indices for

12that dimension: For a dimension of length N, indices can range from 0 to N – 1 inclusive. The total number

13of elements in an array is the product of the lengths of each dimension in the array. If one or more of the

14dimensions of an array have a length of zero, the array is said to be empty.

15The element type of an array can be any type, including an array type.

1619.1 Array types

17An array type is written as a non-array-type followed by one or more rank-specifiers:

18array-type:

19

non-array-type rank-specifiers

20

non-array-type:

21

value-type

22

class-type

23

interface-type

24

delegate-type

25

type-parameter

26

rank-specifiers:

27

rank-specifier

28

rank-specifiers rank-specifier

29

rank-specifier:

30

[ dim-separatorsopt ]

31

dim-separators:

32

,

33

dim-separators ,

34A non-array-type is any type that is not itself an array-type.

35The rank of an array type is given by the leftmost rank-specifier in the array-type: A rank-specifier indicates

36that the array is an array with a rank of one plus the number of “,” tokens in the rank-specifier.

37The element type of an array type is the type that results from deleting the leftmost rank-specifier:

38An array type of the form T[R] is an array with rank R and a non-array element type T.

39An array type of the form T[R][R1]…[RN] is an array with rank R and an element type T[R1]…[RN].

329

Соседние файлы в предмете Электротехника