C#如何在按下键后显示下一个WriteLine

时间:2019-01-17 05:13:33

标签: c# console.writeline readkey

基本上在我的代码中,我希望它在用户按下一个键后显示下一行。我以为是ReadKey,但是在按下一个键后它将关闭。

例如

WriteLine("Press any key to display invoice...");
ReadKey(); //this part

WriteLine("***************************");
WriteLine("***  Corporation ***");
WriteLine("Customer Invoice \r\n");
WriteLine("SHIP TO: ");

1 个答案:

答案 0 :(得分:2)

程序结束前,您还需要另一个ReadKey

Console.WriteLine("Press any key to display invoice...");
Console.ReadKey(); //this part

Console.WriteLine("***************************");
Console.WriteLine("***  Corporation ***");
Console.WriteLine("Customer Invoice \r\n");
Console.WriteLine("SHIP TO: ");

// if you dont do this, the program ends and you cant see the other lines
Console.ReadKey();