Geeks With Blogs
AzamSharp Some day I will know everything. I hope that day never comes.
I was making an application couple of days ago in which I had to take input from the Console. The input was string so I thought I can achieve this using
string myInput = Console.ReadLine() 
But unfortunatly Console.ReadLine() only takes 256 characters as input and once 256 characters are typed it will stop taking input from the user. There is a simple way you can increase the input size. In the code below I am setting the OpenStandardInput method of the Console class to the number of characters that I want to take as input which in this case is 2000 charaters.

byte[] bytes = new byte[2000]; 
Stream inputStream = Console.OpenStandardInput(bytes.Length); 
Console.SetIn(new StreamReader(inputStream)); 
Console.WriteLine("Enter the body of the email"); 
string body = Console.ReadLine(); 

Posted on Wednesday, July 6, 2005 2:54 PM | Back to top

Comments on this post: Console.ReadLine() can only takes 256 characters !!

# re: Console.ReadLine() can only takes 256 characters !!
Requesting Gravatar...
I posted a solution to this here:
Left by Dylan on Jun 28, 2007 7:04 PM

Your comment:
 (will show your gravatar)

Copyright © Mohammad Azam | Powered by: