4.2. Understanding C# Arrays

As I would guess you are already aware, an array is a set of data items, accessed using a numerical index. More specifically, an array is a set of contiguous data points of the same type (an array of ints, an array of strings, an array of SportsCars, and so on). Declaring an array with C# is quite straightforward. To illustrate, create a new Console Application project (named FunWithArrays) that contains a helper method named SimpleArrays(), invoked from within Main():

class Program { static void Main(string[] args) { Console.WriteLine("***** Fun with Arrays *****"); SimpleArrays(); Console.ReadLine(); } static void SimpleArrays() { Console.WriteLine("=> Simple Array Creation."); // Assign an array of ints containing ...

Get Pro C# 2010 and the .NET 4 Platform, Fifth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.