Tag Archives: GetLowerBound

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

Make arrays with non-zero lower bounds in C#

In C#, arrays have 0 as their lower bounds. This is true for arrays declared as in the following: string[] names = new string[10]; string[,] phone_numbers = new int[10, 2]; However, sometimes it would be more convenient to use an … Continue reading

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