From fda6835b72e1461db967ce1725778361f45bf696 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20Gajdu=C5=A1ek?= <gajdusek.pavel@gmail.com> Date: Fri, 22 Sep 2017 11:23:14 +0200 Subject: [PATCH] added csharp --- docs.it4i/software/csc.md | 78 +++++++++++++++++++++++++++++++++++++++ mkdocs.yml | 1 + 2 files changed, 79 insertions(+) create mode 100644 docs.it4i/software/csc.md diff --git a/docs.it4i/software/csc.md b/docs.it4i/software/csc.md new file mode 100644 index 000000000..df231ece1 --- /dev/null +++ b/docs.it4i/software/csc.md @@ -0,0 +1,78 @@ +# 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 +``` + +This command should not return any error status. You can try to remove one of the curly brackets to get error output: + +```console +csc.cs(7,246): error CS1525: Unexpected symbol `end-of-file +Compilation failed: 1 error(s), 0 warnings +``` + +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/). diff --git a/mkdocs.yml b/mkdocs.yml index 881f5e024..c60b9a2fc 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -138,6 +138,7 @@ pages: - Trilinos: software/numerical-libraries/trilinos.md - 'Programming Languages': - Java: software/java.md + - C#: software/csc.md - 'Phys': - LMGC90: salomon/software/phys/LMGC90.md - 'Tools': -- GitLab