✅ Chessboard

How do I ensure that there is a line break after spielfeld[i,26].
string[,] Spielfeld = new string[27, 27];
char gleich = '\u2550';
char linksoben = '\u2554';
char rechtsoben = '\u2557';


Console.Write(Spielfeld[0,1] = " ");
Console.Write(Spielfeld[0,2] = (linksoben).ToString());

for (int j = 0; j < Spielfeld.GetLength(1); j++) {
for (int i = 0; i < Spielfeld.GetLength(1); i++)
{
Spielfeld[0, i] = (gleich).ToString();
Console.Write(Spielfeld[0, i]);
if (i == 26)
{
Console.WriteLine();
}
}
Console.Write(Spielfeld[0, 26] = (rechtsoben).ToString());

}
string[,] Spielfeld = new string[27, 27];
char gleich = '\u2550';
char linksoben = '\u2554';
char rechtsoben = '\u2557';


Console.Write(Spielfeld[0,1] = " ");
Console.Write(Spielfeld[0,2] = (linksoben).ToString());

for (int j = 0; j < Spielfeld.GetLength(1); j++) {
for (int i = 0; i < Spielfeld.GetLength(1); i++)
{
Spielfeld[0, i] = (gleich).ToString();
Console.Write(Spielfeld[0, i]);
if (i == 26)
{
Console.WriteLine();
}
}
Console.Write(Spielfeld[0, 26] = (rechtsoben).ToString());

}
29 Replies
SparkyCracked
SparkyCracked3mo ago
Aren't you already doing that by Console.Writeline under your if (i == 26)?
Nicolas Matheisen
yeah but doesnt work and I dont understand why
SparkyCracked
SparkyCracked3mo ago
Might be due to your loop
Waffles from Human Resources
Why are you coding in German :SCgetoutofmyhead:
SparkyCracked
SparkyCracked3mo ago
c#
string[,] Spielfeld = new string[27, 27];
char gleich = '\u2550';
char linksoben = '\u2554';
char rechtsoben = '\u2557';

Console.Write(Spielfeld[0, 1] = " ");
Console.Write(Spielfeld[0, 2] = (linksoben).ToString());

for (int j = 0; j < Spielfeld.GetLength(1); j++) {
for (int i = 0; i < Spielfeld.GetLength(0); i++) { // We changed the loop condition a bit
Spielfeld[j, i] = (gleich).ToString(); // Use j instead of 0 for the row index
Console.Write(Spielfeld[j, i]);
}
Console.WriteLine(); // Moved the WriteLine here to ensure a line break after each row
if (j == 0) {
Console.Write(Spielfeld[0, 26] = (rechtsoben).ToString());
}
}
c#
string[,] Spielfeld = new string[27, 27];
char gleich = '\u2550';
char linksoben = '\u2554';
char rechtsoben = '\u2557';

Console.Write(Spielfeld[0, 1] = " ");
Console.Write(Spielfeld[0, 2] = (linksoben).ToString());

for (int j = 0; j < Spielfeld.GetLength(1); j++) {
for (int i = 0; i < Spielfeld.GetLength(0); i++) { // We changed the loop condition a bit
Spielfeld[j, i] = (gleich).ToString(); // Use j instead of 0 for the row index
Console.Write(Spielfeld[j, i]);
}
Console.WriteLine(); // Moved the WriteLine here to ensure a line break after each row
if (j == 0) {
Console.Write(Spielfeld[0, 26] = (rechtsoben).ToString());
}
}
Nicolas Matheisen
;D cause the king and knight have the same starting letter and in germany its unquie :devilish:
SparkyCracked
SparkyCracked3mo ago
We start the loop earlier so it accommodates for 26, if you start from 1, it may ignore the last value (26) For the change of 0 to j, just making sure we assign it to the correct row of each array instead of the hardcore 0. Lemme know if that works and does what you need
Nicolas Matheisen
ok :3 ty try to understand this
Nicolas Matheisen
thx it work
SparkyCracked
SparkyCracked3mo ago
Nice
Nicolas Matheisen
Its a good Idea to do comments? I read it in ur code and sry I am a bloody beginner XD HaaaahhNOOOB
SparkyCracked
SparkyCracked3mo ago
Normally yes. I add comments to all my changes by habbit because my senior wants them. Also I work a lot with teams when coding so habbit
Nicolas Matheisen
Hmm yeah its friendlyer if someone red ur code jeah I try to do it too
SparkyCracked
SparkyCracked3mo ago
I am also beginner. I have just done something similar to your issue so I could help. In my case we coded pyramids...
Nicolas Matheisen
U do it realy good atm we learn hardware :/
SparkyCracked
SparkyCracked3mo ago
Nice. Don't do too much though. You'll pick it up though don't stress <3 I learnt that from gaming haha. Where I studied we just did coding 24/7
Nicolas Matheisen
yes my bigger problem is to remember the stuff after month ;D
SparkyCracked
SparkyCracked3mo ago
Ah I see. If I see you online on the server I'll remind you and ask how it's going then ^^
Nicolas Matheisen
;D run yeah do it ty for teaching
SparkyCracked
SparkyCracked3mo ago
No stress bro <3 Have a good one
Nicolas Matheisen
U2
SparkyCracked
SparkyCracked3mo ago
Just close the post on the top right...the three dots
SparkyCracked
SparkyCracked3mo ago
No description
leowest
leowest3mo ago
slightly different here $close
MODiX
MODiX3mo ago
Use the /close command to mark a forum thread as answered
Nicolas Matheisen
ty @leowest
SparkyCracked
SparkyCracked3mo ago
Ahh thanks