En extension som ger en tvådimensionell array som en endimensionell ström:
public static ArrayExtensions {
public static IEnumerable<T> Flatten<T>(this T[,] items) {
for (int i = 0; i < items.GetLength(0); i++) {
for (int j = 0; j < items.GetLength(1); j++) {
yield return items[i, j];
}
}
}
}
Exempel:
bool equal = arr1.Flatten().SequenceEquals(arr2.Flatten()));