Ask coding questions

← Back to all posts
How to do typewriter effect in c#
Bunnytoes (147)

I always wanted to be able to do this and the only way I know is
Console.Write("H");
System.Threading.Thread.Sleep(200);
Console.Write("e");
System.Threading.Thread.Sleep(200);
Console.Write("l");
System.Threading.Thread.Sleep(200);
Console.Write("l");
System.Threading.Thread.Sleep(200);
Console.Write("o");
System.Threading.Thread.Sleep(200);

Comments
hotnewtop
Coder100 (18187)

ez

using System.Threading;
using System;

void TypeWriter(string text, int time = 200) {
  foreach (char c in text) {
    Console.Write(c);
    Thread.Sleep(time);
  }
}

TypeWriter("haiiiii");