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"?
基础教程推荐
- WPF 模态进度窗口 2022-01-01
- 禁止输入少量字符,例如'<'、'&a 2022-01-01
- 当值可以是对象或空数组时反序列化 JSON 2022-01-01
- 如果有人提交恶意软件Nuget包怎么办? 2022-01-01
- 我应该在后面的代码中直接使用 Linq To SQL 还是使 2022-01-01
- Azure Functions:CosmosDBTrigger 未在 Visual Studio 中触发 2022-01-01
- C# 从 List<List<int>> 中删除重 2022-01-01
- Moq It.Is<>不匹配 2022-01-01
- 如何使用 .Net 检查 Active Directory 服务器是否已启动并正在运行? 2022-01-01
- .NET SerialPort DataReceived 事件未触发 2022-01-01
