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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. why does thsi misbehave at times?

why does thsi misbehave at times?

Scheduled Pinned Locked Moved C#
questioncsharphelplearning
3 Posts 3 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.
  • R Offline
    R Offline
    rahulmballal
    wrote on last edited by
    #1

    I have been doin C# for quite some time. When i am doing some console apps for my course assignments i use System.Console.Read(); as a replacement for the getch() that we used to do in C for making the cursor stop. so that the output window doesn close before i can see the output. It works at times and at times it doesnt! Please help me out folks cuz i have ended up using timers for a silly thing like that!! Rahul

    S 1 Reply Last reply
    0
    • R rahulmballal

      I have been doin C# for quite some time. When i am doing some console apps for my course assignments i use System.Console.Read(); as a replacement for the getch() that we used to do in C for making the cursor stop. so that the output window doesn close before i can see the output. It works at times and at times it doesnt! Please help me out folks cuz i have ended up using timers for a silly thing like that!! Rahul

      S Offline
      S Offline
      S Senthil Kumar
      wrote on last edited by
      #2

      Remember that console input is buffered, so if there are character in the buffer that were not yet consumed by your app, Console.Read will return immediately, returning the first character in the buffer. Unfortunately, I don't know of any way to clear the buffer using managed code, fflush(stdin); works for C++. Regards Senthil _____________________________ My Blog | My Articles | WinMacro

      L 1 Reply Last reply
      0
      • S S Senthil Kumar

        Remember that console input is buffered, so if there are character in the buffer that were not yet consumed by your app, Console.Read will return immediately, returning the first character in the buffer. Unfortunately, I don't know of any way to clear the buffer using managed code, fflush(stdin); works for C++. Regards Senthil _____________________________ My Blog | My Articles | WinMacro

        L Offline
        L Offline
        Leather99
        wrote on last edited by
        #3

        Starting the project without Debug in VS2003 will prevent the console from closing until you press return. Also, have you tried Console.ReadLine()? This will only return when the user hits Return.

        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