Hi
what are the C# equivalents of the C++ functions: _getch and kbhit ?
_getch and kbhit can be used in Console Applications. kbhit returns true if a key is pressed and the queue is nonempty. _getch gets the character contained in the queue and empties it out of the queue.
5 replies to this topic
#1
Posted 04 December 2011 - 06:54 AM
I wrote this ebook! Will you translate it into English for free!?:confused: PM me!
|
|
|
#2
Posted 04 December 2011 - 07:11 AM
If you're working with Console applications then it would be:
Console.Read(); Console.ReadKey(); Console.ReadLine();
Think my post we're usefull? Please take your time and press the Like button at my post, Big Thanks!
For great C# & Android tutorials visit my blogg: http://www.thecompboy.com/
For great C# & Android tutorials visit my blogg: http://www.thecompboy.com/
#3
Posted 04 December 2011 - 07:24 AM
ok this code:
kbhit returns true only if there are any characters in statndard input queue.
char ch = Console.ReadKey().KeyChar;works like _getch(). But how about kbhit?
kbhit returns true only if there are any characters in statndard input queue.
Edited by irancplusplus, 04 December 2011 - 10:04 AM.
I wrote this ebook! Will you translate it into English for free!?:confused: PM me!
#4
Posted 04 December 2011 - 07:31 AM
I found something like this on the web:
Is it what you're looking for? If not please explain your question one more time :D
Quote
Sometimes people want a way to use a kbhit() like function in C# at the Console.
while( true )
{
if( Console.KeyAvailable ) // since .NET 2.0
{
char c = Console.ReadKey().KeyChar ;
Console.Write( c );
}
}Is it what you're looking for? If not please explain your question one more time :D
Think my post we're usefull? Please take your time and press the Like button at my post, Big Thanks!
For great C# & Android tutorials visit my blogg: http://www.thecompboy.com/
For great C# & Android tutorials visit my blogg: http://www.thecompboy.com/
#5
Posted 04 December 2011 - 08:42 AM
Exactly.
Thanks.
Thanks.
I wrote this ebook! Will you translate it into English for free!?:confused: PM me!
#6
Posted 04 December 2011 - 09:00 AM
Anytime.
Think my post we're usefull? Please take your time and press the Like button at my post, Big Thanks!
For great C# & Android tutorials visit my blogg: http://www.thecompboy.com/
For great C# & Android tutorials visit my blogg: http://www.thecompboy.com/
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users


Sign In
Create Account


Back to top









