Tag Archives: initialize arrays

Initialize an array of arrays in C#

The example Initialize two-dimensional arrays in C# explains how to initialize a two-dimensional array. An array of arrays is somewhat similar to a two-dimensional array but with some syntax differences. The following code shows how this example declares and initializes … Continue reading

Posted in arrays, syntax | Tagged , , , , , , , , , , , | Leave a comment

Initialize two-dimensional arrays in C#

The example Initialize arrays, lists, and class instances in C# explains how to initialize a one-dimensional array. You can use a similar syntax to initialize multi-dimensional arrays. Use a new statement to indicate the type of array you are initializing. … Continue reading

Posted in arrays, syntax | Tagged , , , , , , , , , , | 1 Comment

Declare and initialize empty arrays in C#

This is a handy trick for working with possibly empty arrays. A C# program cannot use an array’s properties and methods until the array is instantiated. For example, the following code declares an array and then tries to use its … Continue reading

Posted in arrays, syntax, tips | Tagged , , , , , , , , , , , , , , | Leave a comment