The following is a 2D array of vectors in Python:
neighbor = [[1, 3, 0, 0], [2, 4, 0, 1], [2, 5, 1, 2],
[4, 6, 3, 0], [5, 7, 3, 1], [5, 8, 4, 2],
[7, 6, 6, 3], [8, 7, 6, 4], [8, 8, 7, 5]];
How can I rewrite this into C#?
CodePudding user response:
You can do like this:
int[,] neighbor = new int[,] {{1, 3, 0, 0}, {2, 4, 0, 1}, {2, 5, 1, 2},
{4, 6, 3, 0}, {5, 7, 3, 1}, {5, 8, 4, 2},
{7, 6, 6, 3}, {8, 7, 6, 4}, {8, 8, 7, 5}};
Or like this
int[,] neighbor = {{1, 3, 0, 0}, {2, 4, 0, 1}, {2, 5, 1, 2},
{4, 6, 3, 0}, {5, 7, 3, 1}, {5, 8, 4, 2},
{7, 6, 6, 3}, {8, 7, 6, 4}, {8, 8, 7, 5}};
Microsoft article for reference: https://docs.microsoft.com/pt-br/dotnet/csharp/programming-guide/arrays/multidimensional-arrays