如何VS编译控制台应用程序,以显示与QUOT; preSS任意键继续"?控制台、应用程序、继续、VS

2023-09-02 21:47:18 作者:Chafferer(恶作剧)

当我开发一个C#控制台应用程序(这将在服务器上运行),我运行它使用Visual Studio,我得到一个preSS任意键继续的程序结束前的消息。

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#code文件,我的程序不显示该消息并完成它的逻辑后立即终止。

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.

有谁知道如何编译code时,不使用VS,并在不改变C#code任何添加的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,并用该消息出现,不添加任何写(线)/读取(线)的召唤

推荐答案

您可以编写一个运行的exe文件,为您和提示用户preSS的关键批处理脚本。

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

批处理脚本会是这个样子:

The batch script would look something like this:

echo off
YourApp.exe
pause