【问题标题】:c# how to display next WriteLine after pressing a keyc#如何在按键后显示下一个WriteLine
【发布时间】:2019-01-17 05:13:32
【问题描述】:

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

举例

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

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

【问题讨论】:

  • 您可能需要在末尾添加另一个Console.ReadKey() 语句以防止控制台窗口关闭
  • 卫生署!谢谢。

标签: c# console.writeline readkey


【解决方案1】:

在程序结束之前你需要另一个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(); 

【讨论】:

    猜你喜欢
    • 2013-08-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-11-29
    • 2018-04-04
    • 1970-01-01
    • 1970-01-01
    • 2015-12-21
    相关资源
    最近更新 更多