首页 > 解决方案 > 输入整数用户输入后继续程序c#

问题描述

当我运行我的代码时,在控制台中输入一个数字后,我的控制台突然关闭。

int age;
        Console.WriteLine("How old are you?");

        age = Convert.ToInt32(Console.ReadLine());
        Console.WriteLine("You are {0} years old", age);

有人可以帮我解决这个问题吗?我永远看不到最终结果,因为它只是关闭了。没有弹出错误,但它变得非常令人沮丧。

标签: c#integeruser-input

解决方案


添加Console.ReadLine()Console.ReadKey()作为最后一行。


推荐阅读