Category Archives: C#

C#

Raspberry Pi and Mono – Hello World!

This post will walk through installing mono, compiling, and running the Hello World! code example on a Raspberry Pi

At the time of writing:

  • Raspberry Pi 2, Model B, 1GB RAM
  • Linux: Raspbian 8.0 “Jessie”
  • C#

Update package lists

sudo apt-get update

Install Mono complete

Since we will be compiling our Hello World! program on the Pi we will install the mono-complete package.  If you just wanted to run a complied executable (.exe) all you need is the mono-runtime package.

sudo apt-get install mono-complete

Make your directory and write the code

We’re not making a Solution or Project here, simply writing a C# source file and compiling it.

Create the “project” directory

Using your favorite text editor (I’m using the pre-installed nano here) create your program.

nano HelloWorld.cs

Write the code

Type or paste the following code

Exit and save

Compile the code

mcs HelloWorld.cs

See your executable

Run it!

mono HelloWorld.exe

Links

Mono Project: http://www.mono-project.com/

Built from: http://logicalgenetics.com/raspberry-pi-and-mono-hello-world/