O'Reilly logo

Visual C#® 2012: How to Program, Fifth Edition by Harvey Deitel, Paul Deitel

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

8.3. Declaring and Creating Arrays

Arrays occupy space in memory. Since they’re objects, they’re typically created with keyword new. To create an array object, you specify the type and the number of array elements as part of an array-creation expression that uses keyword new. Such an expression returns a reference that can be stored in an array variable. The following declaration and array-creation expression create an array object containing 12 int elements and store the array’s reference in variable c:

int[] c = new int[ 12 ];

This expression can be used to create the array shown in Fig. 8.1 (but not the initial values in the array—we’ll show how to initialize the elements of an array momentarily). This task also can be performed as follows: ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required