Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# CSharp
C# is available on the cluster. Activate C# by loading the Mono module:
```console
$ ml Mono
```
## Examples
### Hello World
Copy this code to new file hello.cs:
```csc
using System;
class HelloWorld {
static void Main() {
Console.WriteLine("Hello world!!!");
}
}
```
Compile the program and make *Windows executable*.
```console
$ mcs -out:hello.exe hello.cs
```
Now run the program:
```console
$ mono hello.exe
Hello world!!!
```
### Interactive Console
Type:
```console
$ csharp
Mono C# Shell, type "help;" for help
Enter statements below.
csharp>
```
Now you are in interactive mode. You can try following example.
```csc
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
false
```
Show all files modified in last 5 days:
```csc
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/script.sh" }
```
For more informations look at [Mono documentation page](http://www.mono-project.com/docs/).