Basically I want 200 characters maximum to come up in Console.ReadLine() for user input before characters start being suppressed. I want it like TextBox.MaxLength except for console input. How would I go about this?
And I don't want to do input.Substring(0, 200).
Solved:
I used my own ReadLine function which was a loop of Console.ReadKey().
It looks like this, essentially:
StringBuilder sb = new StringBuilder();
bool loop = true;
while (loop)
{
ConsoleKeyInfo keyInfo = Console.ReadKey(true); // won't show up in console
switch (keyInfo.Key)
{
case ConsoleKey.Enter:
{
loop = false;
break;
}
default:
{
if (sb.Length < 200)
{
sb.Append(keyInfo.KeyChar);
Console.Write(keyInfo.KeyChar);
}
break;
}
}
}
return sb.ToString();
Thanks everyone