c# - printing string char by char/timer -


i making text-based game, wanted make intro text printing slowly(char char difference of ~100ms) tried making loop loops through string , prints chars 1 one, need timer inbetween wasn't able achieve of google. need making timer or algorithm in order print strings slowly. code:

static void printslowly(string print) {     foreach(char l in print) {         console.write(l);         //timer here     }     console.write("\n"); } 

nasty, nasty cheap solution :

static void printslowly(string print) {     foreach(char l in print) {         console.write(l);         thread.sleep(10); // sleep 10 milliseconds         }     console.write("\n"); } 

since don't care performance, go this. keep in mind thread.sleep pretty wasteful


Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -