C#: Basic Concepts
I am going to start today’s post by outlining some of the basics concepts of Microsoft’s C#-language:
Like Java, which compiles to Bytecode and are executed by a Java virtual machine, C# compiles to an intermediate language known as Microsoft Intermediate Languare (MSIL). C# is closely linked to the .net-framework, for which it was originally designed, and this framework defines an environment that supports the development and execution of component-based applications. This is illustrated by C#’s ability to work in mixed-language environments – this capability of different languages to work toghether constitutes a common programming model for the Windows platform:

This .net-framework provides two important entities for C#:
- Common Language Runtime (CLR): The system that manages the execution of the program. As mentioned, a C#-program is compiled to to MSIL, and then a Just-In-Time (JIT) compiler converts MSIL into native code at demand basis. This is similar to Java’s bytecode-system, and allows programs to be portable. Unilke bytecode, however, it also supports mixed-language programming since other languages (such as Visual Basic, for example) alsom compiles to MSIL.
- Class library of the .net-framework: This framework gives the program access to the runtime environment. For example, if you want to perform I/O such as displaying something on the screen, you will use the .net-framework to accomplish this. As long as the program restricts itself to the features defined by the .net-framework class library, the program will run anywhere that the .net runtime system is supported. Now, since C# automatically uses the .net framewirk class library, programs are automatically portable to all .net-environments.
A basic C#-program
In contrast to Java, the name of a C#-program is arbitrary. It is, however, good practice to name a file after the name of the principal class. Example of a basic program:
using System;
class Example
{
// A C# program begins with a call to Main().
public static void Main()
{
Console.WriteLine("A simple C# program.");
}
}
To compile this, the command line compiler can be used:
C:\>csc Example.cs
This will create the executable file Example.exe. Of course, when using C# professionally one often operates from within Visual Studio and are therefore rarely uses command-line compiling. Nevertheless, it can be useful to have knowledge of this method as well.
In the next line of posts I will dive into the nuts and bolts of the C#-langugage itself so stay tuned for further updates.
