Hey guys, I downloaded the project and code directly from Rob Mile’s website. I clicked start to run it and I just get a cmd prompt window. I can input a number and press enter, then do it again for the other input and then the window just closes. It doesn’t return a string with the calculation.
What am I missing here? Perhaps I’m not running the code right (I just clicked the Start button in MS Visual Studio 2019) As a total beginner, I’m just following the book. It seemed to indicate that this was a functioning program already. Thanks for the help.
The console window closing after debug is done is not an error. You can certainly run your app in a windows command window and the output remains.
Your options are to put a breakpoint at the last line, have a line asking for input (do nothing with, but gives the app pause before closing out the console window), or flip off the option by going to “Tools->Options->Debugging->Automatically close the console when debugging stops”
https://docs.microsoft.com/en-us/visualstudio/debugger/general-debugging-options-dialog-box?view=vs-2019
Ok, perhaps someone can explain this. When I open the file "YellowBookSamples.sln"
from the "Code Sample 01 GlazerCalc Program"
folder, the code is there but I get the above error when trying to run it. But if I just take this above code and paste into a new MS Visual Studio 2019 console app project, it runs and works correctly, I get the output strings. What’s up with that?
Add this to the bottom of your Main() method:
Console.Read();
This will keep the console window open waiting for input before it closes. Computers are so good at following instructions they only will do exactly what you tell them. In the original the computer writes the lines and then the program ends so the computer just ends the program.
C# devs
null reference exceptions