बस नीचे वर्णित समस्या से भाग गया। यदि "Console.TreatControlCAsInput = true;", आपको ReadLine() पर दो बार [Enter] दबा देना होगा।TreatControlCAsInput मुद्दा। क्या यह एक बग है?
मैंने नीचे कुछ डेमो कोड लिखा है। मैं यह अनुमान लगाने में सही हूं कि यह कोड .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();
क्या मंच आप इस पर चल रहे हैं? – Oded
मैं इसे विंडोज 7 पर पुन: उत्पन्न कर सकता हूं। ऐसा लगता है कि ** HOME ** बटन –
का कार्य कर रहा है, मुझे लगता है कि यह 2006 में रिपोर्ट किया गया था जहां डिज़ाइन द्वारा बंद किया गया है। http://connect.microsoft.com/VisualStudio/feedback/details/226101/console-treatcontrolcasinput-true-breaks-readline – automatic