Creating a new program using .NET Core

suggest change

First install the .NET Core SDK by going through the installation instructions for the platform of your choice:

After the installation has completed, open a command prompt, or terminal window.

  1. Create a new directory with mkdir hello_world and change into the newly created directory with cd hello_world.
  2. Create a new console application with dotnet new console.

This will produce two files:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>netcoreapp1.1</TargetFramework>
  </PropertyGroup>
</Project>

Program.cs

using System;

namespace hello_world
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");
        }
    }
}
  1. Restore the needed packages with dotnet restore.
  2. Optional Build the application with dotnet build for Debug or dotnet build -c Release for Release. dotnet run will also run the compiler and throw build errors, if any are found.
  3. Run the application with dotnet run for Debug or dotnet run .\bin\Release\netcoreapp1.1\hello_world.dll for Release.

Command Prompt output

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:


Getting Started With C#:
* Creating a new program using .NET Core

Table Of Contents
0 Getting Started With C#
17 Regex
19 Arrays
21 Enum
22 Tuples
24 GUID
27 Looping
36 Casting
46 Methods
88 Events
92 Structs
104 Indexer
106 Stream
107 Timers
109 Threading
127 Caching
135 Pointers
147 C# Script