static void DisplayMatrixWithCross(int[,] matrix) { for (int row = 0; row < matrix.GetLength(0); row++) { for (int col = 0; col < matrix.GetLength(1); col++) { if (row == (col - 5) + 5) { Console.BackgroundColor = ConsoleColor.Yellow; } Console.ResetColor();
if (row == (col + 5) - 5) { Console.ForegroundColor = ConsoleColor.Red; } Console.Write("{0,3} ", matrix[row, col].ToString("00")); } Console.WriteLine(); }}
I want to change the color of cross line matric like X. for now i am able to get from UpperLeft but i need from upperRight as well. It should print the line X in red color. can someone please help in this. below is the example how it should looks like