C# Language Getting started with C# Language Creating a new program using .NET Core

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Insert
> Step 2: And Like the video. BONUS: You can also share it!

Example

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:

    • hello_world.csproj

      <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!");
              }
          }
      }
      
  3. Restore the needed packages with dotnet restore.

  4. 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.

  5. Run the application with dotnet run for Debug or dotnet run .\bin\Release\netcoreapp1.1\hello_world.dll for Release.


Command Prompt output

enter image description here



Got any C# Language Question?