I've found similar questions like so:
But they don't answer the question of- Is it more efficient?
I'm writing a basic little console game in C# that requires repeatedly clearing and writing to the console in order to refresh the game state. In searching for a more efficient way to do this than my current attempt, iterating through the array with a nested for loop and printing it that way, I found this in Java:
Arrays.deepToString(arrayName);
which does what I'm trying to achieve.
Is this more efficient than using nested loops in Java like so?:
String[][] map = new String[10][10]; for (int i = 0; i < 10; i++) { for (int j = 0; j < 10; j++) { map[i][j] = "="; } } boolean firstRun = true; for (int i = 0; i < 10; i++) { for (int j = 0; j < 10; j++) { if (j == 0 && firstRun == false) { System.out.print("\n"); } System.out.print(map[i][j]); firstRun = false; } }
If it is more efficient, is there a C# library equivalent? I can't seem to find one or even someone asking about one anywhere.