Проблема TreatControlCAsInput. Это ошибка?

Только что наткнулся на проблему, описанную ниже. Если «Console.TreatControlCAsInput = true;», вам нужно дважды нажать [ввод] в ReadLine ().

Ниже я написал демонстрационный код. Я правильно предполагаю, что этот код демонстрирует ошибку в платформе .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();
12
задан NotMe 17 November 2011 в 14:37
поделиться