c# - 输入整数用户输入后继续程序c#
问题描述
当我运行我的代码时,在控制台中输入一个数字后,我的控制台突然关闭。
int age;
Console.WriteLine("How old are you?");
age = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("You are {0} years old", age);
有人可以帮我解决这个问题吗?我永远看不到最终结果,因为它只是关闭了。没有弹出错误,但它变得非常令人沮丧。
解决方案
添加Console.ReadLine()
或Console.ReadKey()
作为最后一行。
推荐阅读
- swift-playground - 在执行本地进程的 Swift 5.1 游乐场中运行 NSPOSIXErrorDomain
- javascript - 我们如何在输入中使用值为 12-123456 的密码类型转义一些特殊字符,看起来像 **-******
- nearprotocol - Near Protocol 有什么机制来防止 gas 价格反馈循环导致它飙升?
- sql - SQL(Snowflake) - SUMIFS,但条件是在多列条件中为每行设置
- c# - 如何在 C# 的记事本 .txt 文件中添加数据?
- r - 闪亮分类准确率表
- node.js - 如何使用 npm 初始化
我的包裹?找不到命令错误 - python - 无法弄清楚如何从 xml 文件中填充字典
- c++ - 如果我在守护程序初始化中添加延迟,是否会影响启动时加载其他守护程序的方式?
- c# - 组合 await 与 ContinueWith