Home > OS >  How can I make the sentence print out one letter at a time?
How can I make the sentence print out one letter at a time?

Time:10-10

I am trying to make this sentence print out one letter at a time, but I am unsure of how to do it. I did try looking at Thread.Sleep, but it didn't really work out for me.

            string Streamer = "Who is your favorite streamer?";

            char[] charSentence3 = Streamer.ToCharArray();
            Array.Reverse(charSentence3);

            foreach(char Streamerchar in charSentence3)
            {
                Console.WriteLine(Streamerchar);
            }
            Console.ReadLine();

Basically, I just want to make the sentence "Who is your favorite streamer" print out one letter at a time.

CodePudding user response:

        string Streamer = "Who is your favorite streamer?";

        foreach  (char c in Streamer)
        {
            Thread.Sleep(100);
            Console.WriteLine(c);
        }
        Console.ReadLine();

This is what you looking for

CodePudding user response:

You're on the right track...

        string streamer = "Who is your favorite streamer?";
        
        foreach(char streamerchar in streamer)
        {
            Thread.Sleep(500);
            Console.Write(streamerchar);
        }
        Console.ReadLine();

Strings can be enumerated to get their chars

You need to thread.Sleep inside the loop to make it look delayed..

..but that's about it!

  •  Tags:  
  • c#
  • Related