basdewaard Posted December 30, 2002 Posted December 30, 2002 (edited) I'm struggling with something that I thought would have been relatively simple. I'd like the user to enter a character into the console and have the console read it w/o the user having to press <enter>. ie: as soon as the user types a character, have the console read it. I thought the following would help but it hasn't: //read the input... do { ch = (char) Console.Read(); //get the char } while(ch == '\n' || ch == '\r'); Edited December 30, 2002 by basdewaard Quote
*Gurus* divil Posted December 30, 2002 *Gurus* Posted December 30, 2002 The console class that bundles with the framework can't do this, but I can point you to the following article which has a replacement console class which can do what you need. http://www.gotdotnet.com/userarea/keywordsrch.aspx?keyword=consoleEx Quote MVP, Visual Developer - .NET Now you see why evil will always triumph - because good is dumb. My free .NET Windows Forms Controls and Articles
basdewaard Posted January 2, 2003 Author Posted January 2, 2003 Thanks for the link, divil, however I am not finding it easy to get going. After reading readme files I opened the .sln (assuming running the project would link with the existing Console). The ConsoleExTest works (which was initially set as the Startup Project). I then tried to get ConsoleEx going but get an error along the lines of "A project with an Output Type of Class Library cannot be started directly". The message contained more information/suggestions which I tried w/o any luck. I also tried to add (relevant) classes to my project but struggled. Could you perhaps give me a rough idea of how I should go about tackling this? Quote
*Gurus* divil Posted January 2, 2003 *Gurus* Posted January 2, 2003 You'd compile it to a class library, then reference that dll from your other project. I haven't actually used the class myself, so I can't be a lot more help than that at the moment. Quote MVP, Visual Developer - .NET Now you see why evil will always triumph - because good is dumb. My free .NET Windows Forms Controls and Articles
basdewaard Posted January 6, 2003 Author Posted January 6, 2003 Thanks for the reply, divil. That's OK. I'll try again with what you've suggested. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.