Search code examples
c#console.writelinereadkey

c# how to display next WriteLine after pressing a key


Basically in my code I want it to display the next lines after the user presses a key. I thought it was ReadKey, but after I press a key it closes.

For Example

WriteLine("Press any key to display invoice...");
ReadKey(); //this part

WriteLine("***************************");
WriteLine("***  Corporation ***");
WriteLine("Customer Invoice \r\n");
WriteLine("SHIP TO: ");

Solution

  • You need another ReadKey before the program ends

    Console.WriteLine("Press any key to display invoice...");
    Console.ReadKey(); //this part
    
    Console.WriteLine("***************************");
    Console.WriteLine("***  Corporation ***");
    Console.WriteLine("Customer Invoice \r\n");
    Console.WriteLine("SHIP TO: ");
    
    // if you dont do this, the program ends and you cant see the other lines
    Console.ReadKey();