The compiler can determine the length of each dimension for you, so let it do all the hard work:
private int[,,] table = new int[,,]{ {{0,6,2,6,4},{2,2,4,2,8},{4,4,8,4,6},{6,6,2,6,4},{8,8,6,8,2}}, {{0,2,8,8,4},{2,4,6,6,8},{4,8,2,2,6},{6,2,8,8,4},{8,6,4,4,2}}, {{0,4,2,4,4},{2,8,4,8,8},{4,6,8,6,6},{6,4,2,4,4},{8,2,6,2,2}}, {{0,8,8,2,4},{2,6,6,4,8},{4,2,2,8,6},{6,8,8,2,4},{8,4,4,6,2}} };
And this gives you the desired result, except for the title:
StringBuilder stringBuilder = new StringBuilder(); for (int row = 0; row < table.GetLength(0); ++row) { stringBuilder.Append(row.ToString() + "\t"); for (int column = 0; column < table.GetLength(1); ++column) { for (int valueIndex = 0; valueIndex < table.GetLength(2); ++valueIndex) { stringBuilder.Append(table[row, column, valueIndex].ToString()); } stringBuilder.Append("\t"); } stringBuilder.AppendLine(); } string result = stringBuilder.ToString(); Console.WriteLine(result);