Answer the question
In order to leave comments, you need to log in
How to limit the number of input characters in ReadLine()?
There is a variable N, in which an integer number not exceeding 10000 is entered.
How can you limit the number of characters entered by the user to 5 without using if and loops?
Answer the question
In order to leave comments, you need to log in
It is possible through cycles and ReadKey.
But it's better to just let anything drive, and then validate and parse
Under the circumstances, I suspect not. ReadLine simply reads the entire line from the buffer, it has no additional parameters for limiting.
And so the statement of the problem itself implies a cycle and a length check on each cycle.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question