TreatControlCAsInput问题。 这是一个错误吗?

刚碰到下面描述的问题。 如果“Console.TreatControlCAsInput = true;”,则必须在ReadLine()上按[enter]两次。

我在下面写了一些演示代码。 我猜测这段代码演示了.NET 4框架中的错误,这是正确的吗?

Console.Write("Test 1: Console.TreatControlCAsInput = false\nType \"hello\": "); { string readline = Console.ReadLine(); // type "hello" [enter]. Console.WriteLine("You typed: {0}", readline); // Prints "hello". } Console.Write("Test 2: Console.TreatControlCAsInput = true\nType \"hello\": "); Console.TreatControlCAsInput = true; { string readline = Console.ReadLine(); // type "hello" [enter]. Console.WriteLine("You typed: {0}", readline); // Should print "hello" - but instead, you have to press [enter] // *twice* to complete the ReadLine() command, and it adds a "\r" // rather than a "\n" to the output (so it overwrites the original line) } // This bug is a fatal error, because it makes all ReadLine() commands unusable. Console.Write("[any key to exit]"); Console.ReadKey(); 

这是Windows控制台子系统的已知问题 ,并且已于2006年在Microsoft Connect上报告。

微软于2007年5月22日12:37发布

您好AROS,感谢您在System.Console中报告此问题。 Windows控制台子系统存在此行为,如附带的Win32 C应用程序所示。 我已将此问题报告给Windows控制台子系统所有者。

谢谢,乔希

不是框架上的错误,但它看起来像Windows控制台子系统中的错误。