Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
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 3 elements {0, 1, 2}
int[] myInts = new int[3];
// Initialize a 100 item string array, indexed {0 - 99}
string[] booksOnDotNet = new string[100];
Console.WriteLine();
}
}