2

I wish to add a "..." effect after the end of one of my strings in a console application I'm building. For example,

Hello World. > Hello World.. > Hello World...

The problem is, how can I do this so that the dots are not shown straight away? But in more a sequential fashion, ie one after another, maybe a new dot is shown every half second or so.

Any help/advice/guidance is greatly appreciated, Thanks

Ari
  • 1,026
  • 6
  • 20
  • 31
  • 1
    Something like: http://stackoverflow.com/questions/888533/how-can-i-update-the-current-line-in-a-c-sharp-windows-console-app? – dugas Jan 31 '12 at 03:11

2 Answers2

3

You could use Thread.Sleep(milliseconds) in between the Console.Write(".") statements.

for(int i = 0;i < 5;i++)
{
  Console.Write(".");
  Thread.Sleep(500);
}
Jimmy Miller
  • 1,317
  • 9
  • 13
3

Try this:

        for (int dots = 0; dots <= 3; ++dots)
        {
            Console.Write("\rHello world{0}", new string('.', dots));
            System.Threading.Thread.Sleep(500); // half a sec
        }

        Console.WriteLine("\nAll done.");
Richard Schneider
  • 34,944
  • 9
  • 57
  • 73