P. 1
(Ebook Pdf) Visual Studio C Sharp Book

(Ebook Pdf) Visual Studio C Sharp Book

|Views: 296|Likes:
Published by api-26658409

More info:

Published by: api-26658409 on Dec 04, 2009
Copyright:Attribution Non-commercial


Read on Scribd mobile: iPhone, iPad and Android.
download as PDF, TXT or read online from Scribd
See more
See less









083601-X Ch07.F 10/18/01 12:00 PM Page 138

Á Type the code that
outputs the opening string
and establishes the array in
the Main method.

‡ Type the code that
outputs the array by iterating
through each element using
the foreach statement.

° Run the program by
pressing the F5 key.

I The prime number array
appears on the screen.

· Save the program as the


You can omit optional parts of the single-dimensional array
argument. One way is to omit the size of the array.

int[] values = new int[] {1, 2, 3, 5, 7, 11};

string[] letters = new string[] {"A", "B", "C"};

Another way is to omit the new statement altogether.

int[] values = {1, 2, 3, 5, 7, 11};

string[] letters = {"A", "B", "C"};


083601-X Ch07.F 10/18/01 12:00 PM Page 139


⁄ Click Start Programs
Microsoft Visual Studio .NET
7.0 Microsoft Visual
Studio .NET 7.0.

I The Start page appears.

¤ Click New Project.

I The New Project window

‹ Click the Console
Application icon in the
Templates pane.

› Type a name for the file.

ˇ Click OK.

C# lets you declare multidimensional arrays for

processing a large number of values in one
argument. A multidimensional array arranges its data
similar to the way a spreadsheet does.

C# multidimensional arrays let you specify two or three
elements in the array for two-dimensional and three-
dimensional arrays, respectively. You can use two-
dimensional arrays for specifying coordinates such as with
the row and column in a spreadsheet, on a map, or on a
game board such as those for checkers and chess.
Programmers use two-dimensional arrays for such tasks as
image processing.

A three-dimensional array lets you specify three elements.
For example, you can store a name in three dimensions —
first name, middle name, and last name.

Just as with single-dimensional arrays, you can specify the
number of elements in each dimension in the rectangular
brackets after you declare the array type. If you think of the
array as the table, C# lists the number of rows first and the
number of columns second. If you have a three-dimensional
array, then the third dimension appears last in the bracket.

You can also specify initial values for the array in the same
order as you have them in the rectangular brackets. Like
single-dimensional arrays, values appear in curly braces
after you initialize the array with the new operator.

Activity (14)

You've already reviewed this. Edit your review.
1 thousand reads
1 hundred reads
edijhon5815 liked this
Ronald Nagario Panjaitan added this note
it's good ref
altabaie liked this
Yousuf Khan liked this
Yousuf Khan liked this
Júlio Gallinaro Maranho liked this
byancaa liked this
peterangka liked this

You're Reading a Free Preview

/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->