Skip to content


C# is available on the cluster.

$ ml av mono

-------------------- /apps/modules/lang ---------------


Use the ml av mono command to get up-to-date versions of the modules.

Activate C# by loading the Mono module:

$ ml Mono


Hello World

Copy this code to a new file hello.cs:

using System;

class HelloWorld {
  static void Main() {
    Console.WriteLine("Hello world!!!");

Compile the program and make Windows executable.

$ mcs -out:hello.exe hello.cs

Now run the program:

$ mono hello.exe
Hello world!!!

Interactive Console


$ csharp
Mono C# Shell, type "help;" for help

Enter statements below.

Now you are in the interactive mode. You can try the following example:

csharp> using System;
csharp> int a = 5;
csharp> double b = 1.5;
csharp> Console.WriteLine("{0}*{1} is equal to {2}", a,b,a*b);
5*1.5 is equal to 7.5
csharp> a == b

Show all files modified in last 5 days:

csharp> using System.IO;
csharp> from f in Directory.GetFiles ("mydirectory")
      > let fi = new FileInfo (f)
      > where fi.LastWriteTime > DateTime.Now-TimeSpan.FromDays(5) select f;
{ "mydirectory/mynewfile.cs", "mydirectory/" }


MPI is available for mono:

using System;
using MPI;

class MPIHello
    static void Main(string[] args)
        using (new MPI.Environment(ref args))
           Console.WriteLine("Greetings from node {0} of {1} running on {2}",

Compile and run the program:

$ qsub -I -A DD-13-5 -q qexp -l select=2:ncpus=24,walltime=00:30:00

$ ml

$ mcs -out:csc.exe -reference:/apps/tools/ csc.cs

$ mpirun -n 4 mono csc.exe
Greetings from node 2 of 4 running on cn204
Greetings from node 0 of 4 running on cn204
Greetings from node 3 of 4 running on cn199
Greetings from node 1 of 4 running on cn199

For more information, see the Mono documentation page.