How to install Mono on Ubuntu 16.04

Watch out! This tutorial is over 7 years old. Please keep this in mind as some code snippets provided may no longer work or need modification to work on current systems.
Tutorial Difficulty Level    

Sponsored by Microsoft, Mono is an open source implementation of Microsoft’s .NET Framework based on the ECMA standards for C#and the Common Language Runtime. A growing family of solutions and an active and enthusiastic contributing community is helping position Mono to become the leading choice for development of cross platform applications.

You can easily install Mono on your Ubuntu 16.04 server. First ensure that your server has the latest versions of all of the tracked repositories, which means you get the latest versions of Mono.

sudo apt-get update

 

Now install the required package:

sudo apt-get install mono-complete

 

Wasn’t that easy?!  You can now run your .NET Applications on Linux.

After you get Mono installed, it’s probably a good idea to run a quick Hello World program to make sure everything is set up properly. That way you’ll know that your Mono is working before you try writing or running a more complex application.

To test the most basic functionality available, copy the following code into a file called hello.cs.

using System;
 
public class HelloWorld
{
    static public void Main ()
    {
        Console.WriteLine ("Hello Mono World");
    }
}

 

To compile, use mcs:

csc hello.cs

 

The compiler will create “hello.exe”, which you can run using:

mono hello.exe

 

The program should run and output:

Hello Mono World