Simple Console question


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 5 of 5

Thread: Simple Console question

  1. #1
    Steve Guest

    Simple Console question


    Hi All,

    I have created a console apllication in visual studio and written it in c#,
    the problem i have is when i run it, it displays the console and closes it
    straight away, before i have a chance to read the results.

    How can i stop the console from closing by itself ?

    Is there some way i can get the console to prompt for a key to be pressed
    before it will close or something like that ?

    Thanks

    Steve

  2. #2
    Mattias Sjögren Guest

    Re: Simple Console question

    Steve,

    >How can i stop the console from closing by itself ?
    >
    >Is there some way i can get the console to prompt for a key to be pressed
    >before it will close or something like that ?


    Add a Console.ReadLine() at the end of your Main method. Or use Start
    Without Debugging (Ctrl+F5) to run the application.


    Mattias

    ===
    Mattias Sjögren (VB MVP)
    mattias @ mvps.org
    http://www.msjogren.net/dotnet/

  3. #3
    Bob Rafuse Guest

    Re: Simple Console question

    > I have created a console apllication in visual studio and written it in
    c#,
    > the problem i have is when i run it, it displays the console and closes it
    > straight away, before i have a chance to read the results.
    >
    > How can i stop the console from closing by itself ?


    Run the console program from a command prompt.

    Bob.



  4. #4
    Betty Buhr Guest

    Re: Simple Console question

    On Tue, 14 May 2002 15:26:20 -0400, "Bob Rafuse" <bobrafuse@yahoo.com>
    wrote:

    >> I have created a console apllication in visual studio and written it in

    >c#,
    >> the problem i have is when i run it, it displays the console and closes it
    >> straight away, before i have a chance to read the results.
    >>
    >> How can i stop the console from closing by itself ?

    >
    >Run the console program from a command prompt.
    >
    >Bob.
    >


    If you are running it from VS.net use Cntl-F5 (start without
    debugging) instead of F5 (start).

  5. #5
    Mauro Fiore Guest

    Re: Simple Console question


    First of return and close the application insert
    this command.
    Console.Writeline();
    In this manner the program is waiting for.
    To close the application press Return key.


    Betty Buhr <bettyb@flamingo-code.com> wrote:
    >On Tue, 14 May 2002 15:26:20 -0400, "Bob Rafuse" <bobrafuse@yahoo.com>
    >wrote:
    >
    >>> I have created a console apllication in visual studio and written it

    in
    >>c#,
    >>> the problem i have is when i run it, it displays the console and closes

    it
    >>> straight away, before i have a chance to read the results.
    >>>
    >>> How can i stop the console from closing by itself ?

    >>
    >>Run the console program from a command prompt.
    >>
    >>Bob.
    >>

    >
    >If you are running it from VS.net use Cntl-F5 (start without
    >debugging) instead of F5 (start).



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center