Thread: how do I pause a console app?

  1. #1
    Registered User
    Join Date
    Aug 2004
    Posts
    731

    how do I pause a console app?

    How do I pause a console app in c# so the window stays open until the user presses enter or something.

    I have just started c#...

  2. #2

  3. #3
    Registered User
    Join Date
    Aug 2004
    Posts
    731
    umm sory those are for c++ and don't work in c#...

  4. #4
    Registered User Draco's Avatar
    Join Date
    Apr 2002
    Posts
    463
    oh, my mistake . I don't know all the differences between C++ and C#, I'll look them up.

  5. #5
    Registered User dalek's Avatar
    Join Date
    May 2003
    Posts
    135
    I just use:

    Code:
    Console.ReadLine();
    Its exactly the same principle as in C++ etc.

  6. #6
    Registered User
    Join Date
    Sep 2001
    Posts
    4,912
    That'll work for pressing enter (which I believe is what you originally asked for), but you can also get it to return on a keypress by using Console.Read(). If I remember correctly this will actually return an integer which will need to be typecasted to a char for data processing, but if you're just pausing, a simple call to Console.Read()'ll do the trick.

  7. #7
    Registered User
    Join Date
    Aug 2004
    Posts
    731
    thanks I can actually do some stuff now!

  8. #8
    Registered User
    Join Date
    Aug 2004
    Posts
    731
    the read or readline functions didn't work.

    And don't worry I know how they work I got a really nice c# book and it taught me that capitals matter and so on. So I garantee you I did put them in corectly and it did compile, but it still didn't pause.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Console App w/ Threads and Events?
    By sean in forum C# Programming
    Replies: 1
    Last Post: 07-02-2004, 12:16 AM
  2. Need help migrating console app to windows app
    By DelphiGuy in forum C++ Programming
    Replies: 1
    Last Post: 03-14-2004, 07:05 PM
  3. MSVC Console app - two enters?
    By LuckY in forum Windows Programming
    Replies: 4
    Last Post: 12-30-2003, 02:13 PM
  4. pause program at console
    By datainjector in forum C# Programming
    Replies: 1
    Last Post: 03-27-2003, 12:36 AM
  5. Project Builder console app
    By Luigi in forum C++ Programming
    Replies: 0
    Last Post: 12-28-2002, 07:57 PM