-3

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.

T-T
  • 19
  • 1
  • 6
  • What problem did you experience with the code you provided? – Anthony Forloney Oct 09 '21 at 22:19
  • Thread.sleep(100); Console.Write(Streamerchar); – Mehrdad Dowlatabadi Oct 09 '21 at 22:22
  • @AnthonyForloney Sorry, I just wanted to implement something that would make my code be able to print out one letter at a time. I searched for awhile of how I could do this, but I did not get many results or I got python results. I do not have it in my code, but I thought I could receive some help of how I could do this and how to insert it into the code. – T-T Oct 09 '21 at 22:24
  • @MehrdadDowlatabadi Would I have to insert the Thread.Sleep(100); before the Console.Write(StreamerChar);? It is not working for me. – T-T Oct 09 '21 at 22:30
  • do u want a type writer effect? look here: https://stackoverflow.com/questions/25337336/how-to-make-text-be-typed-out-in-console-application – Mehrdad Dowlatabadi Oct 09 '21 at 22:37

2 Answers2

3

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!

Caius Jard
  • 72,509
  • 5
  • 49
  • 80
  • Oooh I see, thank you I was getting confused where to put the Thread.Sleep, thanks again! – T-T Oct 09 '21 at 23:47
2
        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

P01NT1
  • 33
  • 5