this is my code for my two dimensional table.
What I want to do is that I put my input on the correct spot - But as you can see, my output of the table is not as it should be. The columns are overlapping the rows. My question is: How can I put columns a bit more to the right. And also - how can i get my input on the correct position ?
Some tips and help are appreciated.
string[,] clubs = new string[20, 30];
clubs[1, 0] = " ADO";
clubs[2, 0] = " Ajax";
clubs[3, 0] = " AZ";
clubs[4, 0] = " FC-GR";
clubs[5, 0] = " FC-TW";
clubs[6, 0] = " FC-U";
clubs[7, 0] = " FEY";
clubs[8, 0] = " HER";
clubs[9, 0] = " NAC";
clubs[10, 0] = " NEC";
clubs[11, 0] = " PSV";
clubs[12, 0] = " RKC";
clubs[13, 0] = " ROD";
clubs[14, 0] = " SC";
clubs[15, 0] = " SPA";
clubs[16, 0] = " VIT";
clubs[17, 0] = " VVV";
clubs[18, 0] = " WIL";
clubs[0, 1] = "Ado Den haag";
clubs[0, 2] = "Ajax";
clubs[0, 3] = "AZ";
clubs[0, 4] = "FC Groningen";
clubs[0, 5] = "FC Twente";
clubs[0, 6] = "FC Utrecht";
clubs[0, 7] = "Feyenoord";
clubs[0, 8] = "Hercules Almelo";
clubs[0, 9] = "NAC Breda";
clubs[0, 10] = "NEC";
clubs[0, 11] = "PSV";
clubs[0, 12] = "RKC Waalwijk";
clubs[0, 13] = "Roda JC";
clubs[0, 14] = "SC Heerenveen";
clubs[0, 15] = "Sparta Rotterdam";
clubs[0, 16] = "Vitesse";
clubs[0, 17] = "VVV-Venlo";
clubs[0, 18] = "Willem II";开发者_运维百科
int rows = 15;
int colums = 15;
int x = 0;
int y = 0;
string str;
int thuisteam;
int uitteam;
Console.WriteLine("Selecteer de thuisteam op een nummer");
for (int i = 1; i < colums; i++)
{
Console.WriteLine(clubs[i, 0] + " " + i);
}
str = Console.ReadLine();
thuisteam = Int32.Parse(str);
Console.WriteLine("Selecteer de uitteam in onderstaande nummer");
for (int i = 1; i < rows; i++)
{
Console.WriteLine(clubs[0, i] + " " + i);
}
str = Console.ReadLine();
uitteam = Int32.Parse(str);
Console.WriteLine("Schrijf de score of datum van je wedstrijd op");
str = Console.ReadLine();
clubs[thuisteam, uitteam] = str;
Console.WriteLine();
for (; y < rows; y++)
{
for (; x < colums; x++)
{
Console.Write(clubs[x, y] + " ");
if (x == (colums - 1))
{
Console.WriteLine("");
Console.WriteLine("");
}
}
x = 0;
}
Console.ReadLine();
}
}
}
It is possible to set the cursor position within the Console: Console.SetCursorPosition. Figuring out the x/y position of the cursor should be as simple as counting rows and characters per column.
Have you considered generating an html Table rather than a text-table? This will avoid the issues with alignment (which the browser will compute for you), and won't require a less-than-readable fixed-width font; not to mention the fact that you can do quite a bit fancier formatting.
Raed this and you'll have no problems
精彩评论