1. Introduction
The PDF for this document is available |HERE|.
The examples in this document are available |HERE|.
C# is a relatively new language. It was available in successive beta versions starting in 2000 before being officially released in February 2002 alongside Microsoft’s .NET 1.0 platform, to which it is tied. C# can only run within this runtime environment. This environment provides programs running within it with a very large set of classes. As a rough approximation, one could say that the .NET platform is a runtime environment analogous to a Java virtual machine. However, there are two notable differences:
- Java has run on various platforms (Windows, Unix, Macintosh) since its inception. In 2002, the .NET platform ran only on Windows machines. For several years now, the Mono [http://www.mono-project.com] project has made it possible to use the .NET platform on operating systems such as Unix and Linux. The current Mono .NET Framework (February 2008) supports .NET Framework 1.1 and elements of .NET Framework 2.0.
- The .NET platform allows the execution of programs written in different languages. The only requirement is that the compiler for these languages be able to generate .NET code (Intermediate Language), which is executed by the .NET virtual machine. All .NET classes are available to .NET-compatible languages, which tends to blur the differences between languages to the extent that programs make extensive use of these classes. The choice of a .NET language becomes a matter of preference rather than performance.
In 2002, C# used the .NET 1.0 platform. At that time, C# was largely a “copy” of Java, and .NET was a class library very similar to that of the Java development platform. When learning the language, one could switch from a C# environment to a Java environment without feeling too out of place. There were even tools available to convert source code from one language to the other. Since then, things have changed. Each language and each development platform now has its own specific features. It is no longer as straightforward to transfer skills from one domain to another.
C# 3.0 and the .NET Framework 3.5 bring many new features. The most significant is likely LINQ (Language INtegrated Query), which allows for uniform querying—in a manner similar to that of the SQL language— sequences of objects from in-memory structures such as arrays and lists, from databases (SQL Server only for now—February 2008), or from XML files.
This document is not a comprehensive course. For example, LINQ is not covered here. It is intended for people who already know programming and want to learn the basics of C#. It is a revision of the original document published in 2002.
Several books helped me write this course:
For version 2002:
- Professional C# Programming, Wrox Publishing
- C# and .NET, Gérard Leblanc, Eyrolles
At the time, I found both of these books to be excellent. Since then, Gérard Leblanc has published updated versions, including the following:
- C# and .NET 2005, Gérard Leblanc, Eyrolles
For the 2008 revision, I used the following sources:
- the original 2002 document. This document, which was a copy-and-paste from my Java course, contained both typos and more serious errors, such as stating that primitive types like System.Int32 were classes when they are actually structures. My bad...
- the Visual Studio Express 2008 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 have ever read.
Serge Tahé, May 2008
Since May 2008, C# has, of course, evolved. However, this document remains relevant for learning the language. As a supplement to this course, you will find a presentation of the 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