✅ 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
SparkyCracked10mo ago
Aren't you already doing that by Console.Writeline under your if (i == 26)?
Nicolas Matheisen
Nicolas MatheisenOP10mo ago
yeah but doesnt work and I dont understand why
SparkyCracked
SparkyCracked10mo ago
Might be due to your loop
The Fog from Human Resources
Why are you coding in German :SCgetoutofmyhead:
SparkyCracked
SparkyCracked10mo 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
Nicolas MatheisenOP10mo ago
;D cause the king and knight have the same starting letter and in germany its unquie :devilish:
SparkyCracked
SparkyCracked10mo 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
Nicolas MatheisenOP10mo ago
ok :3 ty try to understand this
Nicolas Matheisen
Nicolas MatheisenOP10mo ago
thx it work
SparkyCracked
SparkyCracked10mo ago
Nice
Nicolas Matheisen
Nicolas MatheisenOP10mo ago
Its a good Idea to do comments? I read it in ur code and sry I am a bloody beginner XD HaaaahhNOOOB
SparkyCracked
SparkyCracked10mo 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
Nicolas MatheisenOP10mo ago
Hmm yeah its friendlyer if someone red ur code jeah I try to do it too
SparkyCracked
SparkyCracked10mo 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
Nicolas MatheisenOP10mo ago
U do it realy good atm we learn hardware :/
SparkyCracked
SparkyCracked10mo 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
Nicolas MatheisenOP10mo ago
yes my bigger problem is to remember the stuff after month ;D
SparkyCracked
SparkyCracked10mo 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
Nicolas MatheisenOP10mo ago
;D run yeah do it ty for teaching
SparkyCracked
SparkyCracked10mo ago
No stress bro <3 Have a good one
Nicolas Matheisen
Nicolas MatheisenOP10mo ago
U2
SparkyCracked
SparkyCracked10mo ago
Just close the post on the top right...the three dots
SparkyCracked
SparkyCracked10mo ago
No description
leowest
leowest10mo ago
slightly different here $close
MODiX
MODiX10mo ago
Use the /close command to mark a forum thread as answered
Nicolas Matheisen
Nicolas MatheisenOP10mo ago
ty @leowest
SparkyCracked
SparkyCracked10mo ago
Ahh thanks
Want results from more Discord servers?
Add your server