using System; namespace Gameboard.ShogiUI.BoardState { public static class Extensions { public static void ForEachNotNull(this Piece[,] array, Action action) { for (var x = 0; x < array.GetLength(0); x++) for (var y = 0; y < array.GetLength(1); y++) { var piece = array[x, y]; if (piece != null) { action(piece, x, y); } } } } }