Jump to content
  • Advertisement
Sign in to follow this  
Space Moses

question 1 of 356,000

This topic is 4437 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Ok, I have a problem. I am trying to switch over from C++ to C#...and i dont know what is going on. Im taking it one step at a time. First question: How do I pause the screen? In C++ it is simply " system("pause"); "...

Share this post


Link to post
Share on other sites
Advertisement
Hmm, ok --

First of all, why would you want to 'pause' the screen in this way? To see output? If so, you can always run your console app through the terminal (go into Run, type cmd and navigate to the appropriate directory....)

However, if you really want to 'pause', you could always do the equivalent of a cin call... Console.ReadLine(); ...or some other equivalent. Personally I don't like the idea of artificially stalling the execution of your program like this. There's a number of other ways to get output etc so I guess the final word is consider why you're doing this in the first place?

[EDIT] Just for references sake, MSDN uses Console.ReadLine() -- check out this on the MSDN and see how they end their program. Just because MS shows you the way doesn't mean it's a good idea though ;)


~Shiny.


[Edited by - Shiny on April 30, 2006 2:51:49 AM]

Share this post


Link to post
Share on other sites
I use "getch()" from <conio.h> for a simple pause.
There are many other ways, such as loops and what not, that will have the same effect.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
You have to pinvoke this C function into your C# application. Luckily, this process is very easy. There are a few steps:

1) Insert System.Runtime.InteropServices to your using clauses.
2) Insert this line in your class (usually in the first few lines)

[DllImport("msvcrt.dll")]
static extern bool system(string str);

3) In that same class, simply write this:
system("pause");

Hope that helps!

Share this post


Link to post
Share on other sites
This is absurd.

System("PAUSE") is a nasty and unnecessary icky. C# for console now like the new? Run from console, console stays and no closure.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Are you afraid of a few milliseconds loss in a console application? Are you afraid of portability loss when you're obviously targeting the Windows operating system with C#? For my apps, Console.ReadLine() does enough for a quick solution.

Share this post


Link to post
Share on other sites
Quote:
Original post by Anonymous Poster
Are you afraid of a few milliseconds loss in a console application? Are you afraid of portability loss when you're obviously targeting the Windows operating system with C#? For my apps, Console.ReadLine() does enough for a quick solution.


Are you afraid of logging in?

[edit] And by the way, the "right" way of going about it (if you're too lazy to open up a console window), is to go to Debug->Start Without Debugging.


jfl.

Share this post


Link to post
Share on other sites
Quote:
Original post by jflanglois
Quote:
Original post by Anonymous Poster
Are you afraid of a few milliseconds loss in a console application? Are you afraid of portability loss when you're obviously targeting the Windows operating system with C#? For my apps, Console.ReadLine() does enough for a quick solution.


Are you afraid of logging in?

[edit] And by the way, the "right" way of going about it (if you're too lazy to open up a console window), is to go to Debug->Start Without Debugging.


jfl.


nice... lol.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!