# Sunday, April 15, 2007
« Sunday Morning Fun | Main | .NET methods should default to virtual »
I just wrote my first Mono c# program, talk about easy.  The hardest part was figuring out how to invoke the mono c# compiler, and no its not csc, but mcs.  Mono can be installed from the Ubuntu "Add Applications" applet, but its actually easier and more direct to install it from the shell:

sudo bash
apt-get install mono mono-gmcs


Once Mono is installed you may want to install a text editor or MonoDevelop.  I just installed a text editor, called Cream, which actually picked up the syntax highlighting which surprised me.  Anyway I preceded to put together helloworld.cs in my home directory:

using System;

namespace SNeal
{
    public class HelloWorld
    {
        public static void Main(string[] args)
        {
            Console.WriteLine("Hello World, from Ubuntu!");
        }
    }
}

Then from the shell again:

mcs helloworld.cs

Which produced helloworld.exe which can then be run (very similar to Java in this respect) by typing:

mono helloworld.exe


That's all there is to it!  Further things I plan to try out on Ubuntu with Mono: Generics, ASP.NET, NUnit, MonoDevelop, and Eclipse (which is my favorite IDE).

Comments are closed.