
I want to display a chessboard, but the fields are displayed on the left instead of the right side of the numbers.
the description of the chessboard is:
Create a method with signature void DisplayChessboard(ChessPiece[,] chessboard).
This method displays the chessboard, including the row-numbers and column-letters (see screenshot below). Hint: if row + column is even, then use a light background color (e.g. Gray), otherwise use a dark background color (e.g. DarkYellow). For now, print 3 spaces for each cell. ā Call this method DisplayChessboard from the Start method.
in the picture below is how i want it to look like.
In my head it should work fine but it doesn't when i run it.

using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace assignment1
{
internal class Program
{
private static void Main(string[] args)
{
Program myProgram = new Program();
myProgram.Start();
}
private void Start()
{
ChessPiece[,] chessboard = new ChessPiece[8, 8]; // create 2dim array which is the chessboard
InitChessboard(chessboard);
DisplayChessboard(chessboard);
}
private void InitChessboard(ChessPiece[,] chessboard) // Fills chessboard with value null
{
for (int row = 0; row < chessboard.GetLength(0); row++)
{
for (int col = 0; col < chessboard.GetLength(1); col++)
{
chessboard[row, col] = null;
}
}
}
private void DisplayChessboard(ChessPiece[,] chessboard) // Displays the chessboard
{
int[] numbers = { 8, 7, 6, 5, 4, 3, 2, 1 };
char[] letters = { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h' };
for (int row = 0; row < chessboard.GetLength(0); row++)
{
Console.WriteLine(numbers[row]); // displays the numbers
for (int col = 0; col < chessboard.GetLength(1); col++)// fills chessboard with colors
{
if ((row + col) % 2 == 0)
{
Console.BackgroundColor = ConsoleColor.Gray;
}
else
{
Console.BackgroundColor = ConsoleColor.DarkYellow;
}
Console.Write(" ");
Console.ResetColor();
}
}
for (int i = 0; i < letters.Length; i++) // displays the letters
{
Console.Write($" {letters[i]}");
}
}
}
}