Tag Archives: randomize array

Randomize two-dimensional arrays in C#

This example uses the following extension method to randomize two-dimensional arrays. // Randomize a 2D array. public static void Randomize<T>(this T[,] values) { // Get the dimensions. int num_rows = values.GetUpperBound(0) + 1; int num_cols = values.GetUpperBound(1) + 1; int … Continue reading

Posted in algorithms, extension methods, mathematics | Tagged , , , , , , , , , , | Leave a comment

Make extension methods that randomize arrays and lists in C#

This example uses the techniques described in the post Randomize arrays in C# to make extensions methods that randomize arrays and lists. Extension methods must be in a public static class. This example creates a RandomizationExtensions class. That class declares … Continue reading

Posted in algorithms, extension methods, mathematics | Tagged , , , , , , , , , , , | 1 Comment

Randomize arrays in C#

This example builds a Randomizer class that lets you randomize arrays. It provides a generic Randomize method that randomizes an array containing any kind of data. The following code shows the class. public class Randomizer { public static void Randomize<T>(T[] … Continue reading

Posted in algorithms, mathematics | Tagged , , , , , , , , , , | 7 Comments