Search code examples
c#arraysstringconsole.writeline

C#: Large amounts of text cut off when read by program


Hi I cant seem to find any useful information regarding how to store information into an array from a console.writeline.

 Console.WriteLine("Please enter one or more sentences.");
 string text = Console.ReadLine();

How would I store the users sentence into an array? as currently if I enter a large amount of text it is getting cut of hopefully an array will allow for all of the text to be read and sorted. Thank you!!


Solution

  • It's a limit of the Console API, it is 256 characters (254 + CR LF). You can change this limit with

    Console.SetIn(new StreamReader(Console.OpenStandardInput(8192)));
    

    Found on MSDN forum: http://social.msdn.microsoft.com/Forums/en/csharpgeneral/thread/51ad87c5-92a3-4bb3-8385-bf66a48d6953

    OR

    you can create a new ReadLine method, check this post: Console.ReadLine() max length?