using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { int[] numbers; int index; numbers = new int[6]; // Create array to hold 6 numbers // We can access an array element using a literal // e.g. to set the third element we can use index // value 2 numbers[2] = 55; Console.WriteLine(numbers[2]); // Displays 55 // But we can access array using variable as index index = 2; numbers[index] = 55; // Also sets third element in array Console.WriteLine(numbers[2]); // Displays 55 // ********************************************** // This means we can combine arrays and for loops // ********************************************** // First element is always at index 0 // Likewise, for loop count value can start with // 0, so we can combine them // This .... numbers[0] = 0; numbers[1] = 0; numbers[2] = 0; numbers[3] = 0; numbers[4] = 0; numbers[5] = 0; // ..becomes this. for (index = 0; index < 6; index++) { numbers[index] = 0; } Console.ReadKey(); // Pause } } }