How can I limit the number of characters for a console input? C#
问题 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);