create and run a console application

To create and run a console application

  • Start Visual Studio.
  • On the menu bar, choose File, New, Project.
  • The New Project dialog box opens.
  • Expand Installed, expand Templates, expand Visual C#, and then choose Console Application.
  • The new project appears in Solution Explorer.
  • If Program.cs isn’t open in the Code Editor, open the shortcut menu for Program.cs in Solution Explorer, and then choose View Code.
  • Replace the contents of Program.cs with the following code.

// “Welcome 2” program in C#.
using System;
namespace Desire2Code
class Welcome
static void Main()
Console.WriteLine(“Welcome 2”);
// Keep the console window open in debug mode.
Console.WriteLine(“Press any key to exit.”);

Choose the F5 key to run the project. A Command Prompt window appears that contains the line Welcome 2