Tag Archives: Array class

Use Array methods in C#

The example Sort and search arrays in C# shows how to use two useful Array methods: Sort and BinarySearch. This example demonstrates some other useful Array methods. For simplicity, this example uses arrays of characters to demonstrate the Array methods, … Continue reading

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

Make a class that wraps arrays with non-zero lower bounds in C#

The example Make arrays with non-zero lower bounds in C# shows how to use the Array class to make an array with non-zero lower bounds. Unfortunately the syntax is unnatural, requiring you to use method calls instead of normal array … Continue reading

Posted in arrays, performance, variables | 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

Copy arrays quickly in C#

It’s easy enough to use a for loop to copy an array, but for most arrays you can get even better performance by using the Array class’s Copy method. This takes as parameters the source and destination arrays. A third … Continue reading

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