为什么Console.Readline()在允许的文本长度上有限制? [英] Why does Console.Readline() have a limit on the length of text it allows?

查看:55
本文介绍了为什么Console.Readline()在允许的文本长度上有限制?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


可能重复:

Console.Readline()最大长度?

我的尝试找到了一个非常简单的文本语音应用程序我认为编写自己的语言会更快。但是,我注意到 控制台。 Readline() 的限制是每行最多254个字符;我在方法文档中找不到有关此限制的任何信息。

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.

这是Windows堆栈中的限制,还是我的代码有问题?我该如何克服?我可以决定使用 Console.Readkey逐个字符地读取字符。 () ,但是我不会冒险将字符丢失到MS DOS哑文本粘贴行为吗?

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?

推荐答案

使用.NET Reflector进行的快速浏览可以看到:

A quick look at implementation with .NET Reflector gives this:

public static Stream OpenStandardInput()
{
    return OpenStandardInput(0x100);
}

public static Stream OpenStandardInput(int bufferSize)
{
  ...
}

256是OpenStandardInput的默认值,所以我想这是设计使然。请注意,这仅适用于.NET,因为Windows API没有此限制。

256 is the default value of OpenStandardInput, so I guess it's by design. Note this is only for .NET as the Windows API does not have this limit.

这篇关于为什么Console.Readline()在允许的文本长度上有限制?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆