How do I code in pauses or delays? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How do I code in pauses or delays?

I'm playing around with the C# right now and I'm creating a chat bot kind of thing to try and apply the concepts that I'm learning into an actual program. I don't really like the instant replies of the bot. How do I make pauses/delays in between each console.writeline() as if someone is actually "typing" it out or taking time to think? Current code with comments in place of where I want pauses: string name; int x = 20; Console.WriteLine("What is your name?"); name = Console.ReadLine(); if (name == "Ryan"){ Console.WriteLine("Your name sucks, {0}.", name); Console.WriteLine("How many years have you disappointed your parents by existing {0}?", name); } else { //pause Console.WriteLine("Nice! How old are you, {0}?", name); } int age = Int32.Parse(Console.ReadLine()); if (0<age && age<21) { Console.WriteLine("Ah, you're but a youngin!"); //pause Console.WriteLine("When I was your age, I was the fastest CPU around!"); //pause Console.WriteLine("Nowadays these old parts can't keep up with all your fancy new i8 cores."); if (age<0) { Console.WriteLine("You're so young you haven't even been born yet!"); } if (age==0) { Console.WriteLine("What a babe."); //pause Console.WriteLine("Smoking hot!"); } if (age==21) { Console.WriteLine("Drink responsibly, young grasshopper."); } if (age>21) { Console.WriteLine("Wow you're one foot in the grave!"); } } else { Console.WriteLine("Ah this must be R??"); } //yes i want an infinite loop of no u while (x < 21) { string reply = Console.ReadLine(); if (reply == "no me") { Console.WriteLine("yes u"); } else { Console.WriteLine("no u"); } x = x--; }

2nd Mar 2018, 8:34 PM
Felina
1 Answer
2nd Mar 2018, 10:56 PM
Toni Isotalo
Toni Isotalo - avatar