Some instructions on how to get started with using Mono in Linux environments: from installation to running your first “Hello World!” example.
Open up your terminal and issue the following commands:
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
echo "deb http://download.mono-project.com/repo/debian wheezy main" | sudo tee /etc/apt/sources.list.d/mono-xamarin.list
sudo apt-get update
sudo apt-get install Mono-Complete
Check that your Mono has installed by using the ‘version’ command:
mono --version
We can now test our installation of Mono by writing some code, in this case the proverbial “Hello World!” example. Open a text editor of your choice and enter the following C# code:
using System; namespace MonoExample { public class HelloWorld { public static void Main(string[] args) { Console.WriteLine("Hello World"); } } }
After saving your code sample eg as ‘main.cs’, using the terminal once more, compile the code by navigating to its location and running the command
mcs main.cs
Finally, to run the ‘main.exe’ that gets generated use the ‘mono’ command:
mono main.exe