5

有什么方法可以让这个程序通过使用 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();

        }
      }
   }
}
4

1 回答 1

2

尝试将它们放在一个while循环中:

var c = "c";

while (c == "c")
{
    Console.WriteLine("Hello");
    Console.WriteLine("press 'c' to continue");
    c = Console.ReadLine();
}
于 2013-10-06T03:50:16.657 回答