Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Console Applications

Console Applications

Scheduled Pinned Locked Moved C#
csharpvisual-studiodebuggingbeta-testingquestion
5 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    Darrall
    wrote on last edited by
    #1

    In Visual Studio 2008 when writing a console application for C# in Debug you were able to click 'start without debugging' to view the results of your program then 'press any key to continue'. Visual Studio 2010 (beta 2) does not offer that option. How do you overcome this?

    C 1 Reply Last reply
    0
    • D Darrall

      In Visual Studio 2008 when writing a console application for C# in Debug you were able to click 'start without debugging' to view the results of your program then 'press any key to continue'. Visual Studio 2010 (beta 2) does not offer that option. How do you overcome this?

      C Offline
      C Offline
      CoderGirl42
      wrote on last edited by
      #2

      Well, if you're concerned that your console window will close too quickly by running it with debugging (i.e. without prompting 'press any key to continue'). You can simply add a call to Console.Readline(); at the end of your Main function. This will keep your console window open until you press a key. for example:

          static void Main(string\[\] args)
          {
              //Do Work
      
              Console.Write("press any key to continue");
              Console.ReadLine(); //prevents console window from closing.
          }
      

      Hope that Helps!

      D C 2 Replies Last reply
      0
      • C CoderGirl42

        Well, if you're concerned that your console window will close too quickly by running it with debugging (i.e. without prompting 'press any key to continue'). You can simply add a call to Console.Readline(); at the end of your Main function. This will keep your console window open until you press a key. for example:

            static void Main(string\[\] args)
            {
                //Do Work
        
                Console.Write("press any key to continue");
                Console.ReadLine(); //prevents console window from closing.
            }
        

        Hope that Helps!

        D Offline
        D Offline
        Darrall
        wrote on last edited by
        #3

        Thank you :) Elegantly simple.

        1 Reply Last reply
        0
        • C CoderGirl42

          Well, if you're concerned that your console window will close too quickly by running it with debugging (i.e. without prompting 'press any key to continue'). You can simply add a call to Console.Readline(); at the end of your Main function. This will keep your console window open until you press a key. for example:

              static void Main(string\[\] args)
              {
                  //Do Work
          
                  Console.Write("press any key to continue");
                  Console.ReadLine(); //prevents console window from closing.
              }
          

          Hope that Helps!

          C Offline
          C Offline
          CTF66
          wrote on last edited by
          #4

          I think you mean ReadKey() - yes?

          N 1 Reply Last reply
          0
          • C CTF66

            I think you mean ReadKey() - yes?

            N Offline
            N Offline
            Not Active
            wrote on last edited by
            #5

            Either one will work. The point is to have the application wait for input before continuing.


            I know the language. I've read a book. - _Madmatt

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups