Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Daniel Solis - Illustrated C# 2010 - 2010.pdf
Скачиваний:
16
Добавлен:
11.06.2015
Размер:
11.23 Mб
Скачать

CHAPTER 14 ARRAYS

Putting It All Together

The following code puts together all the pieces we’ve looked at so far. It creates, initializes, and uses a rectangular array.

//Declare, create, and initialize an implicitly typed array. var arr = new int[,] {{0, 1, 2}, {10, 11, 12}};

//Print the values.

for( int i=0; i<2; i++ ) for( int j=0; j<3; j++ )

Console.WriteLine("Element [{0},{1}] is {2}", i, j, arr[i,j]);

This code produces the following output:

Element [0,0] is 0

Element [0,1] is 1

Element [0,2] is 2

Element [1,0] is 10

Element [1,1] is 11

Element [1,2] is 12

352

Соседние файлы в предмете [НЕСОРТИРОВАННОЕ]