Possible Duplicate:
Console.Readline() max length?
In my attempt to find a very simple text to speech application I decided it was faster to write my own. I noticed, however, that Console.Readline()
is limited in the amount of text it allows per line to 254 characters; I can't find anything about this limit in the method documentation.
Is this a limitation in the Windows stack, or a problem with my code? How can I overcome it? I could decide to read character by character with Console.Readkey()
, but won't I then risk losing characters to the MS DOS dumb text pasting behavior?
One of the most common uses of the ReadLine method is to pause program execution before clearing the console and displaying new information to it, or to prompt the user to press the Enter key before terminating the application.
The C# readline method is mainly used to read the complete string until the user presses the Enter key or a newline character is found. Using this method, each line from the standard data input stream can be read. It is also used to pause the console so that the user can take a look at the output.
The only difference between the Read() and ReadLine() is that Console. Read is used to read only single character from the standard output device, while Console. ReadLine is used to read a line or string from the standard output device.
This is a somewhat bizarre limitation on the Console API. I had this problem before and found the following solutions:
Console.SetIn(new StreamReader(Console.OpenStandardInput(8192)));
From the following MSDN forum post:
http://social.msdn.microsoft.com/Forums/en/csharpgeneral/thread/51ad87c5-92a3-4bb3-8385-bf66a48d6953
See also this related StackOverflow question:
Console.ReadLine() max length?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With