I am constantly switching to console mode from windows application mode when debugging. If my application is in Windows mode, will Console.Read and Console.ReadLine wait for user input?
In a Windows Application, Console.Read will always return -1, Console.ReadLine will return null, ReadToEnd will return string.Empty, and Peek will return -1;
This is because the Console class will automatically install a custom StreamReader to Console.In so these calls avoid being problematic.
No, they will not. They will act as if they didn't exist. One thing to note, though, is that ReadKey will throw an exception rather than ignore it like the other two. If you need to check whether you are in a console or not see this question.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With