Listen for key press in .NET console app

后端 未结 9 1497
隐瞒了意图╮
隐瞒了意图╮ 2020-11-22 05:02

How can I continue to run my console application until a key press (like Esc is pressed?)

I\'m assuming its wrapped around a while loop. I don\'t like

9条回答
  •  暖寄归人
    2020-11-22 05:27

    If you are using Visual Studio, then you can use "Start Without Debugging" in the Debug menu.

    It will automatically write "Press any key to continue . . ." to the console for you upon completion of the application and it will leave the console open for you until a key is pressed.

提交回复
热议问题