CSharp examples for System:Array Dimension
Initialize three dimensional array with function
using System.Text; using System.Linq; using System.Collections.Generic; using System;//w w w .j a v a 2 s . com public class Main{ public static T[, ,] Initialize<T>(this T[, ,] array, Func<int, int, int, T> valueXYZ) { for (int k = 0; k < array.GetLength(2); k++) for (int j = 0; j < array.GetLength(1); j++) for (int i = 0; i < array.GetLength(0); i++) array[i, j, k] = valueXYZ(i, j, k); return array; } public static T[,] Initialize<T>(this T[,] array, Func<int, int, T> valueXY) { for (int j = 0; j < array.GetLength(1); j++) for (int i = 0; i < array.GetLength(0); i++) array[i, j] = valueXY(i, j); return array; } }