I have the following code in C,
Its basically a maze where
S=starting point G=Goal .=open path and #=dead end
char maze[6][6] = {
"S...##",
"#.#...",
"#.##.#",
"..#.##",
"#...#G",
"#.#..."
};
I am trying to convert into c#, here is my attempt
char[,] maze = new char[6,6];
I don’t know how to add the 2dimensional array into this object. basically I want the maze layout in C#.
I also want to be ably to access a point in my maze, for example maze[x][y]==”S” for comparison.
The
char[,]solution is probably the one you want to use but just for kicks if you just need to access elements as `maze[y][x]’ you can use your old code with a slight twist:You’ll have to remember that this is an array of
stringnotcharbut strings model a sequence of chars. This won’t work if you intend on modifying individual elements (like saymaze[3][2] = '.'as strings are immutable.