VS如何编译控制台应用程序以显示“Press any key to continue"? [英] How does VS compile console applications to show "Press any key to continue"?

查看:12
本文介绍了VS如何编译控制台应用程序以显示“Press any key to continue"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我开发 C# 控制台应用程序(将在服务器上运行)并使用 Visual Studio 运行它时,我在程序终止前收到按任意键继续"消息.

When I develop a C# console application (which will run on a server) and I run it using Visual Studio, I get a "Press any key to continue" message before the program terminates.

但是,当我使用 CSC 手动编译相同的 C# 代码文件时,我的程序不会显示该消息,它会在完成其逻辑后立即终止.

However, when I compile the very same C# code file manually using CSC, my program doesn't show that message and it terminates immediately after finishing its logic.

有谁知道我如何在不使用 VS 和不更改 C# 代码的情况下添加 ReadLine() 来编译代码时如何实现相同的功能?

Does anyone know how I can make the same feature when compiling the code without using VS and WITHOUT changing the C# code any adding a ReadLine()?

更新:在我学习 C# 时出现的相同消息,我曾经将 TextPad 与 CSC 一起使用,并且该消息过去没有添加任何 Write(Line)/Read(Line) 调用就出现了

推荐答案

你可以编写一个批处理脚本来为你运行exe并提示用户按键.

You could write a batch script that runs the exe for you and prompts the user to press a key.

批处理脚本如下所示:

echo off
YourApp.exe
pause

这篇关于VS如何编译控制台应用程序以显示“Press any key to continue"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆