public static void Main(string[] args)
{ '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#' },
{ '#', '.', '.', '.', '#', '.', '.', '.', '.', '.', '.', '#' },
{ '#', '.', '#', '.', '#', '.', '#', '#', '#', '#', '.', '#' },
{ '#', '#', '#', '.', '#', '.', '.', '.', '.', '#', '.', '#' },
{ '#', '.', '.', '.', '.', '#', '#', '#', '.', '#', '.', '.' },
{ '#', '#', '#', '#', '.', '#', '.', '#', '.', '#', '.', '#' },
{ '#', '.', '.', '#', '.', '#', '.', '#', '.', '#', '.', '#' },
{ '#', '#', '.', '#', '.', '#', '.', '#', '.', '#', '.', '#' },
{ '#', '.', '.', '.', '.', '.', '.', '.', '.', '#', '.', '#' },
{ '#', '#', '#', '#', '#', '#', '.', '#', '#', '#', '.', '#' },
{ '#', '.', '.', '.', '.', '.', '.', '#', '.', '.', '.', '#' },
{ '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#' }};
mazeTraversal(maze1, 1, 1);
private static bool mazeTraversal(char[,] maze, int row, int col)
if (row == maze.GetLength(0)
|| col == maze.GetLength(1)
else if (maze[row, col] != '.')
maze[row, col] = char.Parse("X");
Console.WriteLine("\n\n-----------------------\n\n");
bool canSolveFromHere = mazeTraversal(maze, row - 1, col)
|| mazeTraversal(maze, row, col + 1)
|| mazeTraversal(maze, row + 1, col)
|| mazeTraversal(maze, row, col - 1);
private static void PrintMatrix<T>(T[,] matrix)
for (int i = 0; i < matrix.GetLength(0); i++)
for (int j = 0; j < matrix.GetLength(1); j++)
Console.Write(matrix[i, j] + " ");