.NET Tutorial - Hello World in 10 minutes

Create your app

In your command prompt, run the following command to create your app:

In your terminal, run the following commands to create your app:

Command prompt
dotnet new console -o myApp

Then, navigate to the new directory created by the previous command:

Command prompt
cd myApp

What do these commands mean?

  • The dotnet new console command creates a new console app for you.
  • The -o parameter creates a directory named myApp where your app is stored and populates it with the required files.
  • The command cd myApp changes your current directory to the one just created for the new app.

The main file in the myApp folder is Program.cs. By default, it already contains the necessary code to write "Hello World!" to the Console.

Program.cs
using System;

namespace myApp
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");
        }
    }
}

Got an error?

If you receive a message similar to Template "Console Application" could not be created. Access to the path 'C:\Windows\System32\myApp' is denied., change your current directory to one where you have permissions to create a new folder and try to run the command again. If you can't resolve the issue, use the I ran into an issue button to get help fixing the problem.

Continue