For gettin input without the user hitting enter in a console application.
Thanks in advance.
For gettin input without the user hitting enter in a console application.
Thanks in advance.
Why drink and drive when you can smoke and fly?
Console.Read() or Console.ReadLine()
To code is divine
Then how do I do it so they dont wait for the user to press enter?
Why drink and drive when you can smoke and fly?
How about _getch()?
Code:using System; using System.Collections.Generic; using System.Text; using System.Runtime.InteropServices; namespace ConsoleApplication1 { class Program { [DllImport("msvcrt")] static extern int _getch(); static void Main(string[] args) { Console.WriteLine("Hello world"); Console.WriteLine("Press any key to end.."); _getch(); } } }
Thanks, Im going to try that.
[edit]
Yep, that did it. Thanks a lot.
Last edited by Marcos; 01-08-2006 at 09:17 PM.
Why drink and drive when you can smoke and fly?
Not a problem.Originally Posted by Marcos
I think it will be better to use Console.ReadKey(true) insteed of
[DllImport("msvcrt")]
static extern int _getch();
Yeah Console.Readkey(true/false) works best.
He who asks is a fool for five minutes, but he who does not ask remains a fool forever.
The fool wonders, the wise man asks. - Benjamin Disraeli
There are no foolish questions and no man becomes a fool until he has stopped asking questions. Charles Steinmetz
AHHH! Zombie Thread!
I copied it from the last program in which I passed a parameter, which would have been pre-1989 I guess. - esbo
Actually I think this one is quite desirable. He did provide new and meaningful information. ReadKey() is indeed the best option. PInvoke is a last resort solution and rarely advisable. The thread just got richer with his post.
Could still be closed at this point though, I guess. But for creating an account just to correct a thread you probably got from a search engine... my hat to you, Kirow. And thanks.
Originally Posted by brewbuck:
Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.
While the info was useful this thread still is considered an old thread and therefore I am going to close it. If anyone would like to discuss the new information feel free to start a new thread about the topic.
Closed.