这是我的代码:
StreamReader reader = new StreamReader("war.txt");
string input = null;
while ((input = reader.ReadLine()) != null)
{
Console.WriteLine(input);
}
reader.Close();
上面的程序从文件“war.txt”中逐行读取并打印出来。我需要重新编写程序,以便它以相反的顺序打印出来,即最后一行在前,第一行在后。例如,如果“war.txt”包含以下内容:
Hello.
How are you?
Thank you.
Goodbye.
该程序应打印出:
Goodbye.
Thank you.
How are you?
Hello.
我是 C# 的新手,请帮忙!谢谢!