This is a book for people who want to learn the C# programming language. I’ve tried my best to avoid making assumptions about any prior programming experience you might or might not have had. The book begins with variables and ends with a program that plays music.
C# is a modern, object-oriented programming language designed at Microsoft. The language is part of a major collection of software technologies collectively called .NET (pronounced “dot net”), unveiled in the summer of 2000 and released about a year and a half later. You can use C# and .NET for Web programming or for writing programs that run under Microsoft Windows.
C# is not the only programming language you can use for .NET programming. Microsoft published a Common Language Specification (CLS) that defines a minimum standard of features that a programming language must have to use .NET. It is expected that many programming languages will be adapted in accordance with the CLS. But C# is the programming language designed specifically for .NET and the language that has the closest fit with the features of .NET.
As the name of the language suggests, C# is a descendent of sorts of the C and C++ programming languages, and it also bears some similarity with Java, a language that was also influenced by C and C++. These C-family languages (as they’re now called) all have similar syntax, but the differences deepen on closer inspection. In particular, C# is part of a trend toward the use of programming languages that sacrifice a little efficiency in favor of safety. As I’ll discuss in the first chapter, C and C++ became popular partially because programs written in these languages are often fast and use a minimum amount of memory. These languages achieve this efficiency by assuming that the programmer is very smart and doesn’t make mistakes; the languages themselves don’t provide any checks to determine if the program is doing anything wrong, such as accessing memory it shouldn’t be accessing. C and C++ programs may be fast, but they can often have bugs that are difficult to diagnose.
Nowadays, machines are fast enough and memory is cheap enough that program efficiency is not a primary concern. What we care about more than efficiency is that programs be as free from bugs as possible. While no programming language lets programmers write entirely bug-free programs, C# goes a long way in comparison with C and C++. For that reason, C# programs are safer to run.