Raspberry Pi

Getting Started with Mono on Raspberry Pi

Mono is a software released by Microsoft that allows the developers to develop the different applications as a part of the “NET framework”. We can easily program the Raspberry Pi with Mono to develop different applications. In this write-up, the method has been discussed to not only install Mono on the Raspberry Pi operating system but also to make a simple Hello program to understand the usage of Mono.

How to install Mono on Raspberry Pi

To install Mono on Raspberry Pi, we will check the availability of the Mono package in the default repository of Raspberry Pi using the apt package manager:

$ apt show mono-complete

Then after confirming the availability, we will install it by running the command:

$ sudo apt install mono-complete -y

When the package has been installed, we will use the command mentioned-below to display the version the application:

$ mono --version

How to program using Mono on Raspberry Pi

Now after the installation, we will simply write the code using Mono to test the application, for this open the file using the nano editor with name “myMonoCode” the “.cs” extension means that it is a C# file:

$ nano myMonoCode.cs

Then type the script mentioned below to display “Hello LinuxHint” on the screen:

using System;
public class HelloWorld
{
    public static void Main(string[] args)
    {
        Console.WriteLine ("Hello LinuxHint");
    }
}

Compile the file using the command:

$ mcs myMonoCode.cs

After compilation an exe file of “myMonoCode” will be made in the same directory which can be run by using the command:

$ mono myMonoCode.exe

In the above figure, we can see the output of the script of file “myMonoCode”.

Conclusion

Mono is the alternative to the Net framework and is used to develop different applications in C, C++ and C#. Mono is available for different operating systems and in this article, Mono has been installed on the Raspberry Pi operating system using the command-line method.

About the author

Hammad Zahid

I'm an Engineering graduate and my passion for IT has brought me to Linux. Now here I'm learning and sharing my knowledge with the world.