1. Introduction
The PDF of this document is available in English |ICI|.
The examples in this document are available at |ICI|.
C# is a recent language. It has been available in successive beta versions since 2000, before being officially released in February 2002 at the same time as Microsoft's .NET 1.0 platform, to which it is linked. C# can only run in this execution environment. It provides programs running within it with a vast array of classes. As a first approximation, the .NET platform can be said to be an execution environment analogous to a Java virtual machine. However, there are two differences:
- Java has been running on various OS (Windows, unix, Macintosh) since its inception. In 2002, the .NET platform only ran on Windows machines. In recent years, the Mono project [http://www.mono-project.com] has made it possible to run the .NET platform on OS machines such as Unix and Linux. The current version of Mono (February 2008) supports .NET 1.1 and elements of .NET 2.0.
- the .NET platform can run programs written in different languages. All that's required is for the compiler to be able to produce IL (Intermediate Language) code, which is then executed by the .NET virtual machine. All .NET classes are available to compatible .NET languages, which tends to erase the differences between languages, as programs make extensive use of these classes. Choosing a .NET language becomes a matter of taste rather than performance.
In 2002, C# used the .NET 1.0 platform. At the time, C# was largely a "copy" of Java and .NET a class library very similar to that of the Java development platform. When learning the language, you could move from a C# environment to a Java environment without feeling out of place. There were even tools for converting source code from one language to the other. Since then, things have evolved. Each language and development platform now has its own specificities. It's no longer so easy to transfer skills from one domain to another.
C# 3.0 and the .NET 3.5 framework bring many new features. Probably the most important is LINQ (Language INtegrated Query), which enables sequences of objects to be queried in a uniform way, similar to the SQL language from in-memory structures such as arrays and lists, databases (SQL Server only for now - February 2008) or XML files.
This document is not an exhaustive course. For example, LINQ is not covered. It is intended for people who already know programming and want to discover the basics of C#. It is a revision of the original document published in 2002.
Several books helped me write this course:
For the 2002 version :
- Professional C# programming, Editions Wrox
- C# et .NET, Gérard Leblanc, Editions Eyrolles
At the time, I thought both books were excellent. Gérard Leblanc has since published updated versions, including the following:
- C# and .NET 2005, Gérard Leblanc, Editions Eyrolles
For the 2008 revision, I used the following sources:
- the original 2002 document. This document, a copy/paste of my Java course, contained both typographical errors and more serious mistakes, such as saying that primitive types like System.Int32 were classes, whereas these are structures. Mea culpa...
- visual Studio Express 2008 MSDN documentation
- the book C# 3.0 in a Nutshell by Joseph and Ben Albahari, published by O'Reilly, one of the best programming books I've ever read.
The source codes for the examples in this document are available at [http://tahe.developpez.com/dotnet/csharp/].
Serge Tahé, May 2008
Since May 2008, C# has of course evolved. However, this document is still relevant for learning this language. In addition to this course, you'll find a presentation of ORM (Object Relational Mapper) Entity Framework in the article " Introduction to ORM Entity Framework 5 Code First"at URL [https://stahe.github.io/en-ef5cf-oct-2012/].
Serge Tahé, October 2013