DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 5 of 5

Hybrid View

  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).



Bookmarks

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


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links