到Console.ReadLine()最大长度? [英] Console.ReadLine() max length?
本文介绍了到Console.ReadLine()最大长度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在运行一小块C#code的,当我尝试输入长串到到Console.ReadLine()
好像一对夫妇后切断行。
When running a small piece of C# code, when I try to input a long string into Console.ReadLine()
it seems to cut off after a couple of lines.
有一个最大长度到Console.ReadLine(),如果是的话是有增加的一种方式?
Is there a max length to Console.Readline(), if so is there a way to increase that?
推荐答案
无需任何修改code我相信这将只需要256个字符作为最大 - 它将使254输入,但会保留2 CR和LF
without any modifications to the code I believe it will only take 256 characters as a max - it will allow 254 to be entered but will reserve 2 for CR and LF
这种方法将有助于增加限制
this method will help to increase the limit
private static string ReadLine()
{
Stream inputStream = Console.OpenStandardInput(READLINE_BUFFER_SIZE);
byte[] bytes = new byte[READLINE_BUFFER_SIZE];
int outputLength = inputStream.Read(bytes, 0, READLINE_BUFFER_SIZE);
//Console.WriteLine(outputLength);
char[] chars = Encoding.UTF7.GetChars(bytes, 0, outputLength);
return new string(chars);
}
这篇关于到Console.ReadLine()最大长度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文