How do i blink the text in console using C#?
I improved Matthew's code a bit using \r and some fancy use of String:
static void Main()
{
string txt = "Hello, world!";
WriteBlinkingText(txt, 500);
}
private static void WriteBlinkingText(string text, int delay)
{
bool visible = true;
while (true)
{
Console.Write("\r" + (visible ? text : new String(' ', text.Length)));
System.Threading.Thread.Sleep(delay);
visible = !visible;
}
}
I also think that the WriteBlinkingText method should be self-contained, so the loop is inside here, but that's just a matter of personal taste I guess :)