C# is a general purpose, type safe programming language implemented with the Object Oriented Paradigm in mind, The following tutorial is aimed at users that already know the basics of programming and are looking for a fast guide to get started with C# and .NET Core on Linux. The whole tutorial is divided into different posts, each containing new topics.

.NET Core is the free and open-source implementation of the .NET Framework. It includes the CoreCLR, CoreFX, CoreRT and a compiler. Have in mind that unlike Microsoft’s dotNET Framework, .NET Core is cross-platform and supports ASP.NET Core apps, command line apps , libraries and Universal Windows apps, but lacks support for WinForms and WPF which leaves us without GUIs. By 2019 Microsoft is planning on porting WinForms to .NET Core but this will only be for Microsoft Windows OS, leaving behind Linux and MacOS. It is important to note to not confuse .NET Core with the Mono framework which are two different things.

What is the CLR

The Common Language Runtime (CLR) is the environment that allows .NET programs to run. The CLR gives us additional services including memory management, remoting, type safety, exception handling, garbage collection, security and thread management.

Installation & Tools

This tutorial series uses Visual Studio Code, which is a free and open source code editor by Microsoft. You may use any other editor or IDE of your liking as long as it supports C# syntax.

DotNet Core Installation

It is suggested using the Fedora .NET SIG copr repository as a way to install .NET Core. Note that software in COPR isn’t supported by Fedora infrastructure or signed by the project.

First, enable the COPR repository:

$ sudo dnf copr enable @dotnet-sig/dotnet

Next, install .NET Core:

$ sudo dnf install dotnet

Alternatively, install from the Microsoft repos, however, these sources are typically a few versions of Fedora behind.

Visual Studio Code Installation

Check out our previous post here on the Fedora Magazine for details on installing Visual Studio Code:

C# extension for VS Code

Next, to install the C# extension for Visual Studio Code, press CTRL + P, and enter the following command:

ext install ms-vscode.csharp

Hello World!

It is now time to start the journey into C# with a traditional Hello World program.

Open up a terminal window and type:

$ dotnet new console -o Hello $ cd Hello

Now open the Program.cs file with your editor and you should see something like this:

using System; namespace Hello

{

class Program

{

public static void Main (string[] args)

{

Console.WriteLine (“Hello World!“);

}

}

}

Next in your terminal window type:

$ dotnet run

And if you did everything right you should see a Hello World! display at your screen.