我正在尝试从文本文件构建表格,但是:当我编译程序时,输入的信息出现在它应该出现的表格之后,但表格是空白的。显然我在某个地方犯了一个错误..你能帮忙吗?
StreamReader swreNames = File.OpenText("Names.txt");
do
{
Console.SetCursorPosition(15, 2);
Console.Write("--- Names Table ---");
Console.SetCursorPosition(10, 4);
Console.Write("First Name");
swrNames.WriteLine(firstname); // Reads from first name from file Names.txt
Console.SetCursorPosition(10, Counter + 6); // Aligns first name within table settings
Console.SetCursorPosition(28, 4);
Console.Write("Surname");
swrNames.WriteLine(lastname); // Reads from last name from file Names.txt
Console.SetCursorPosition(28, Counter + 6);
Console.SetCursorPosition(48, 4);
Console.Write("Age");
swrNames.WriteLine(age); // Reads from age from file Names.txt
Console.SetCursorPosition(48, Counter + 6);
Console.ReadLine();
Console.Clear();
} while ((firstname = swreNames.ReadLine()) != null); //Writes out the input from the text file
好的,我已经编辑了代码以显示我认为有问题的地方,希望它的阅读格式稍微容易一些!
请帮忙。