How to make text be “typed out” in console application?

后端 未结 3 1309
失恋的感觉
失恋的感觉 2021-01-01 05:48

Just like the way the computer does it in War Games. I\'ve started, but I don\'t know where to go from here.

static void TypeLine(string line)
{
    string o         


        
3条回答
  •  时光取名叫无心
    2021-01-01 06:13

    The easiest way may be to Sleep() between characters. Something like this:

    static void TypeLine(string line) {
        for (int i = 0; i < line.Length; i++) {
            Console.Write(line[i]);
            System.Threading.Thread.Sleep(150); // Sleep for 150 milliseconds
        }
    }
    

提交回复
热议问题