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

gcc - MinGW's ld cannot perform PE operations on non PE output file -

timeout - Handshake_timeout on RabbitMQ using python and pika from remote vm -

c# - Search and Add Comment with OpenXML for Word -