c# is a multi-paradigm modern programming language. It is a high level object and component oriented language that is easy to learn and to read. It can be used to develop many types of appllications, specifcally: desktop appplications, web applications, mobile applications and games.
It is created by Microsoft to be run on .NET framework. But it can also be run on an mono framework. Both are free, cross-platform, and Open source. The c# code is compiled to an intermediate language IL, that will be stored with the different resources in an assembly. This assembly will be loaded on the CLR (Common Language Runtime) when the program is excuted. The CLR is simply a virtual execution system that will convert the IL code into native machine code.
How to install it
To use the language you have the option to install 2 different frameworks:
- .NET : you will have to install the .NET SDK. Available for Windows, Linux, and macOS. In this tutorialfrom the official .NET page, you can follow the instructions to install the SDK , to test your installation, and to write your first program in c#
- mono: you can just follow the instructions from this official download page to install the different necessary componnents. The instructions are available for: Windows, Linux, macOS, and Docker.
For more details about the installation on ubuntu, you can check the video below:
The Hello World Example
In the video below, you will see 2 examples of hello world code written in c#:
- the first code : hello.cs will print the message "Hello World!" on a console. To compile and run the code on ubuntu with mono, you can use these 2 commands:
- csc hello.cs
- mono hello.exe
- The second one will create a winodw form with the title "Hello World!". To compile and run the conde on ubuntu with mono you can use these 2 commands:
- csc hello.cs -r:System.Windows.Forms.dll
- mono hello.exe
For additional ressources and more details about the language, you can check the links below:
Something to say ?
If you want to add something about the C# language or about this post, please feel free to do it by commenting below 🙂 .