有没有什么方法可以让这个程序使用Console.ReadLine();两次?
我在下面提供了我的代码,每当我调试时,我只获得第一个上面提供的代码,但当我删除第一个Console.ReadLine();一切都显示出来。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MyFirstProject
{
class Program
{
static void Main(string[] args)
{
String name= "John Berr";
String country = "USA";
String city = "Unknown";
String age = "15";
Console.WriteLine("My name is " + name);
Console.WriteLine("The Country I reside in is " + country);
Console.WriteLine("The city I reside in is " + city);
Console.WriteLine("I am " + age +" years old");
Console.ReadLine();
{
Console.WriteLine("Hello");
Console.ReadLine();
}
}
}
}
答案 0 :(得分:2)
尝试将它们置于while循环中:
var c = "c";
while (c == "c")
{
Console.WriteLine("Hello");
Console.WriteLine("press 'c' to continue");
c = Console.ReadLine();
}