C# Fundamentals: Hello World

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:

Using Visual Studio Code on Fedora

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.

Fedora Project community For Developers


  1. I personally don’t mind C#, but why would I use it? Isn’t it much more sensible to use TypeScript, which has more or less the same syntax but also is fully cross-platform?

    • indrora

      TypeScript is great when you’re targeting JS as a final runtime, and some of TypeScript’s syntax was brought over from C#, but the goal is different.

      TS is, like I said, a language built for JS as a runtime. The goal is to create a strongly typed language on top of JS/ES6. The goal of C# is a strongly typed language for more general purpose tasks which runs on the dotnet (core) runtime, as well as some others after being compiled down into CIL bytecode. It isn’t meant to run in the browser, but instead things like .NETCard (smartcards that run .NET), or .NETMF (.NET on embedded systems, one of the first open .NET projects from Microsoft)

  2. Ilia

    Rider is most powerful IDE for dotnet after Visual Studio with resharper. If you like c# and intellij – you will be surprised.

    • I agree Jetbrain’s Rider is a really powerful tool. I used Visual Studio Code just because it’s a personal preference, but the whole tutorial/guide that I plan to make will be IDE/editor agnostic. It’s nice to see what tools other people use.

  3. Jack

    Excellent introductory article! Easy to follow, and deploy.

  4. Jonathan

    Nice intro article – I had no idea so much work had been done to make this available.

    What’s the future of dotnet on Fedora – any plans to move the packages from the COPR into Fedora proper?

  5. NIkola

    Nice and very helpful tutorial. Thanks 🙂

Comments are Closed

The opinions expressed on this website are those of each author, not of the author's employer or of Red Hat. Fedora Magazine aspires to publish all content under a Creative Commons license but may not be able to do so in all cases. You are responsible for ensuring that you have the necessary permission to reuse any work on this site. The Fedora logo is a trademark of Red Hat, Inc. Terms and Conditions