0

hello i just started the dietel series for c# but in the first chapter he used a peice of code to print hello world and in the screenshot he uses the app holds and doesn't shut down while when i use it it just runs and closes emidtialty i tried to look online and some people said to use console.readline but is it the right implemtation here and will it have any problems in the long run or is the problem with my version of vs (using vs 2017)


// Fig. 3.1: Welcome1.cs
// Text-displaying app.
using System;

class Welcome1
{
  // Main method begins execution of C# app
  static void Main()
  {
     Console.WriteLine("Welcome to C# Programming!");                   
  } // end Main
} // end class Welcome1
  • What problem are you anticipating? As is, this a simple dummy app with no ramifications if it lives or dies. As a result, `Console.ReadLine` is just fine. If you need something more durable down the road, you typically could put in a while loop with an exit condition. – David L Jan 06 '21 at 23:12
  • well my question is it right ? i mean why did the book right it like that ? – Seif Walid Jan 06 '21 at 23:13
  • "right" is highly subjective. How would anyone know if the book wrote it "right", other than the author themselves? The above will not preserve the application without something to pause, so in that sense, no, it is wrong or incomplete. – David L Jan 06 '21 at 23:15
  • thank you for the clarification – Seif Walid Jan 06 '21 at 23:15
  • Configuration of visual studio is managed by each individual using it. Console closing at the end of execution is common but can be changed to stay open for you to see what happened at the end. When the program ends, normally nothing is printed and console is no longer needed. – Jawad Jan 06 '21 at 23:17

0 Answers0