Greeneye Greeneye

Niner since 2013


  • Dissecting the First C# Program You Created - 03

    @Curious:TechAZ has the correct answer.  

    Just a tip from one noob to another: When learning to program you are going to come across many commands in syntax that you don't understand. It would behoove you to learn to answer your own questions.

    For example, in this case you wanted to know what the ReadLine(); was for. Here are some ways I would go about answering that question for myself:

    1. Try removing that segment of the syntax and then executing the program. This approach will generally lead to compile errors but you may see a change in behavior in the program. In this case you would notice the DOS box pop up and immediately disappear.
    2. In the Visual Studio IDE highlight the syntax in question "ReadLine" and then press F1. This will take you to an online resource for the specific method and provide further details.
    3. Next, you can always Google for the answer. Something like "C# ReadLine" or "C# why use ReadLine" The second result from the second search returned a page with this info:

      Pause before exit

      You can insert a Console.ReadLine method call at the end of the Main method—or even in a finally block in the Main method. This will ensure the terminal window is never dismissed by Windows immediately on program completion.

    I hope this helps. I'm not saying you were wrong in asking here, but you can get answers to questions pretty quick if you are willing to put some work in to it.