# Getting started with .NET

The .NET framework was released in 2000 by Microsoft.
An open source implementation of the platform was developed in the form of [Mono](https://www.monodevelop.com/), which was the center of controversy in the early 2000s when it became apparent that Microsoft held several patents for .NET technology and could theoretically use those patents to end implementations of it.
Since then, Microsoft has purchased Xamarin, the company that produces Mono, and in 2014 declared that the .NET development platform would use the MIT license from then on.

Both .NET and Mono have grown into cross-platform programming environments for C#, F#, GTK#, Visual Basic, Vala, and more.
Applications created with .NET and Mono have been delivered to Linux, BSD, Windows, macOS, Android, and even some gaming consoles.
You can use either .NET or Mono to develop .NET applications.
Both are open source and both have active and vibrant communities.
This article provides an overview for Microsoft's implementation of the .NET environment.


## How to install .NET

Downloads for .NET itself is divided into packages containing just a .NET runtime, and the .NET SDK containing .NET Core and runtime.
To start developing with .NET, you must [install the SDK](https://dotnet.microsoft.com/download).
This provides you with the ``dotnet`` terminal or PowerShell command, which helps you create and build projects.

## Linux

To install .NET on Linux, first add the Microsoft Linux software repository to your computer.

On Fedora:

```
$ sudo rpm --import https://packages.microsoft.com/keys/microsoft.asc
$ sudo wget -q -O /etc/yum.repos.d/microsoft-prod.repo https://packages.microsoft.com/config/fedora/27/prod.repo
```

On Ubuntu:

```
$ wget -q https://packages.microsoft.com/config/ubuntu/19.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
$ sudo dpkg -i packages-microsoft-prod.deb
```

Next, install the SDK using your package manager, replacing ``X.Y`` with the current version of the .NET release:

On Fedora:

```
$ sudo dnf install dotnet-sdk-X.Y
```

On Ubuntu:

```
$ sudo apt install apt-transport-https
$ sudo apt update
$ sudo apt install dotnet-sdk-X.Y
```

Once all packages are downloaded and installed, confirm the install by opening a terminal and typing this command:

```
$ dotnet --version
X.Y.Z
```

## Windows

If you're on Microsoft Windows, you probably already have the .NET runtime installed.
However, to develop .NET applications, you must also install the .NET Core SDK.

First, download the installer from [dotnet.microsoft.com/download](https://dotnet.microsoft.com/download).
To keep your options open, download .NET Core for cross-platform development (the .NET Framework is Windowsojp..b-only).
Once the ``.exe`` file has been downloaded, double-click it to launch the install wizard and click through the two-step install process: accept the license, allow the install to proceed.

![Installing dotnet on Windows](dotnet-windows-install.jpg)


Afterwards, open PowerShell from your Application Menu in the lower left corner.
In PowerShell, type a test command:

```
PS C:\Users\osdc> dotnet
```

If you see information about a ``dotnet`` install in return, then .NET has been installed correctly.


## macOS

If you're on an Apple Mac, [download the Mac installer](https://dotnet.microsoft.com/download), which comes in the form of a ``.pkg`` package.
Double-click on the ``.pkg`` file once it's been downloaded and click through the installer.
You may need to grant permission for the installer, as the package is not from the App Store.

Once all packages are downloaded and installed, confirm the install by opening a terminal and typing this command:

```
$ dotnet --version
X.Y.Z
```


## Hello .NET

A sample "hello world" application written in .NET is provided along with the ``dotnet`` command.
Or more accurately, the command itself provides the sample application.

First, create a project directory and the required code infrastructure using the ``dotnet`` command with the ``new`` and ``console`` options to create a new console-only application.
Use the ``-o`` option to specify a project name.

```
$ dotnet new console -o hellodotnet
```

This creates a directory called ``hellodotnet`` in your current directory.
Change into your project directory and have a look around:

```
$ cd hellodotnet
$ dir
hellodotnet.csproj  obj  Program.cs
```

The file ``Program.cs`` is an empty C# file containing a simple ``Hello World`` application.
Open it in a text editor to view it.
Microsoft's Visual Studio Code is a cross-platform, open source application built with ``dotnet`` in mind, and while it's not a bad text editor, it also collects a lot of data about its user (and grants itself permission to do so in the license applied to its binary distribution).
If you want to try out Visual Studio Code, consider using [VSCodium](https://vscodium.com/), a distribution of Visual Studio Code that's built from the MIT-licensed source code *without* the telemetry (read the documentation at [github.com/VSCodium](https://github.com/VSCodium/vscodium/blob/master/DOCS.md) for options to disable other forms of tracking present in even this build).
Alternatively, just use your existing favourite text editor or IDE.

The boilerplate code in a new console application is this:

```
using System;

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

To run the program, use the ``dotnet run`` command:

```
$ dotnet run
Hello World!
```

That's the basic workflow of .NET and the ``dotnet`` command.
The full C# guide is available at [](https://docs.microsoft.com/en-us/dotnet/csharp/tutorials/intro-to-csharp/), and everything you learn there is relevant to .NET.
Try it out, and keep it open!