.NET Tutorial - Hello World in 10 minutes

Edit your code

Open the Program.cs file in any text or code editor, such as Notepad or Visual Studio Code. The Program.cs file is located on the newly created myApp directory.

Then, add the highlighted line after the code that prints "Hello World!", like the following:

Program.cs
using System;

namespace myApp
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");
            Console.WriteLine("The current time is " + DateTime.Now);
        }
    }
}

Save the Program.cs file and run your code again:

Command prompt
dotnet run

If you succeed, you should see an output similar to the following:

Command prompt
Hello World!
The current time is 11/10/2020 8:00:00 AM
Continue