Semicolons in C# terminate a statement, so this one:
for (int i = 0; i < 5; i++) {
for (int j = 0; j < 5; j++);
^
|
Console.Write($"{arr[i,j]} ");
Console.Write("\n");
ends the loop, and does not include any other lines in it. If you look at your code you will see that the indentation reflects that: the Console.Write instruction is not indented at all from the
for
loop above it.
As a result, the variable
j
declared in the loop goes out of scope immediately and is not available in the next line.
This may help you next time you get a compilation error:
How to Write Code to Solve a Problem, A Beginner's Guide Part 2: Syntax Errors[
^]