How does VS compile console applications to show quot;Press any key to continuequot;?(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"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:VS如何编译控制台应用程序以显示“Press any key to continue"?


基础教程推荐
- 经典 Asp 中的 ResolveUrl/Url.Content 等效项 2022-01-01
- 在 VS2010 中的 Post Build 事件中将 bin 文件复制到物 2022-01-01
- 是否可以在 asp classic 和 asp.net 之间共享会话状态 2022-01-01
- JSON.NET 中基于属性的类型解析 2022-01-01
- 首先创建代码,多对多,关联表中的附加字段 2022-01-01
- 从 VS 2017 .NET Core 项目的发布目录中排除文件 2022-01-01
- 错误“此流不支持搜索操作"在 C# 中 2022-01-01
- 将事件 TextChanged 分配给表单中的所有文本框 2022-01-01
- 如何动态获取文本框中datagridview列的总和 2022-01-01
- 全局 ASAX - 获取服务器名称 2022-01-01