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.4. Examples Using Arrays

This section presents several examples that demonstrate declaring arrays, creating arrays, initializing arrays and manipulating array elements.

8.4.1. Creating and Initializing an Array

The app of Fig. 8.2 uses keyword new to create an array of five int elements that are initially 0 (the default for int variables).

 1   // Fig. 8.2: InitArray.cs  2   // Creating an array.  3   using System;  4  5   public class InitArray  6   {  7      public static void Main( string[] args )  8      {  9         int[] array; // declare array named array 10 11         // create the space for array and initialize to default zeros 12         array = new int[ 5 ]; // 5 int elements 13 14         Console.WriteLine( ...

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