相关疑难解决方法(0)

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 …
Run Code Online (Sandbox Code Playgroud)

.net c# .net-4.0

12
推荐指数
1
解决办法
883
查看次数

标签 统计

.net ×1

.net-4.0 ×1

c# ×1