Question

Is there any way that I can make this program display both text by using Console.ReadLine(); twice?

I provided my code below and whenever I debug I only get the ones provided above the first one, but when I remove the first Console.ReadLine(); everything gets displayed.

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();

        }
      }
   }
}
Was it helpful?

Solution

try put them in a while loop:

var c = "c";

while (c == "c")
{
    Console.WriteLine("Hello");
    Console.WriteLine("press 'c' to continue");
    c = Console.ReadLine();
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top