I'm trying to develop a console application for macOs that displays characters with a small delay in between each character, like if someone was typing the lines in the console.
I want to disable the user input while the message is being typed, but I can't figure out how to do it:
static void WriteToConsoleWithDelay(string msg, int delay = 75)
{
var e = msg.GetEnumerator();
while (e.MoveNext())
{
var c = e.Current;
Console.Write(c.ToString());
Thread.Sleep(totalDelay);
}
Console.WriteLine();
}
I believe you want
Console.ReadKey(true)
https://learn.microsoft.com/en-us/dotnet/api/system.console.readkey?view=netframework-4.8