c# - vscode中的Console.ReadLine出现问题
问题描述
大家好,我正在编写我的第一个程序,并且我选择了 C#。我正在尝试在多项选择测验的开头写一个小对话。根据 youtube 视频和论坛,我应该能够执行 WriteLine,然后执行空白 ReadLine,并且在输入任何内容后程序应该继续。但是当我向它提供输入时,它只会放下一行并继续等待提示。这是vscode引起的问题吗?此外,我只是在修改基本的 hello world 脚本。这是一些代码。谢谢。
using System;
namespace C_
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("In 5 seconds the teacher will begin to speak...");
Console.ReadLine();
Console.WriteLine("You will be tested for aptitude in the realm of being a worthy human.");
Console.ReadLine();
}
}
}
解决方案
这是 Visual Studio Code 环境的问题。contains 设置将launch.json
控制您的应用程序的执行方式。
默认情况下,属性:“console”设置为值“internalConsole”。所以它看起来像这样:
“console”:“internalConsole”
为了使用Console.ReadLine();
或Console.ReadKey();
更改为:
“console”:“integratedTerminal”
然后在调试时切换到下方面板中的“终端”。
为了“自动”切换到“终端”面板,添加:
“internalConsoleOptions”:“neverOpen”
推荐阅读
- c# - NI LabVIEW中的AES加密
- php - 无法通过使用标头功能重定向访问其他页面上的会话?
- post - _this.testFormEl.nativeElement.submit 不是 Form Post 的函数
- serialization - 协议缓冲区的长度前缀帧示例
- branch - git 命令检查存储库是否有任何未提交的更改
- c++ - arm-none-eabi-g++ 无法使用 -flto 正确处理弱别名
- django - 在日期时间字段上使用 __range 进行过滤
- python - 统计每个用户的词频
- python - 无法创建 django 测试数据库
- node.js - 如何增加部署在 AWS ECS fargate 上的 Nodejs Socket.io 服务器中的 websocket 客户端数量?