Welcome to my C# tutorial!
This tutorial is aimed at people who are new to programming and looking for a simple tutorial to learn their first programming language. I will try to explain things in all the necessary detail, and will split the tutorial into small chunks, each with a working program to test out. I will assume basic knowledge of how computers work an what a variable is, for example. If you can already program in one language and want to learn another, you can skip some parts of the explanations. If you are an expert programmer and want to learn C#, my tutorial probably isn’t the best place to do so, and I would recommend C# Station’s tutorial, which is what I am using. I started programming with Lego Mindstorms robotics kits, and then free interactive media software called Scratch, which involves dragging blocks to program your sprites’ actions and is a great thing to look at before starting on a typed language like C#. I then started to teach myself C++ and gained an understanding of how code is usually written. I am currently learning C#, as well as writing this tutorial. (I make sure all the code works and the facts are correct, just in case I’m wrong). I aim to write one part every 2 or 3 days.
We will now look at the history of C#. Don’t worry if you don’t understand it – I’m not completely sure just what the .Net framework is, exactly. You will become more familiar with the jargon as you become better at programming.
C# is a general purpose programming language which was developed by Microsoft and first appeared in 2001. It is simple, modern and object orientated. According to Wikipedia, it was built during the development of the.Net framework, when in 1999, Anders Hejlsberg formed a team to work on a language called COOL (C-like Object Orientated Language). Microsoft couldn’t call the language “Cool” because it would produce trademark difficulties, so before releasing it, they renamed it to C#.
The language was influenced by a language called C++, which was influenced by an earlier language called C. In C++, putting two plus signs after a variable increases it by 1, so effectively, C++ takes C up a notch. If you look at the # sign, it is actually made up of four + signs.
Here is a Hello World program in C#, as simply as it can be written:
Please note: If you are using Microsoft Visual C#, the program will end as soon as it has printed the words “Hello World” to the screen, meaning the window will open and then disappear in the blink of an eye. I will include a way to stop this in the slightly more complicated version of a Hello World program, which I will explain in part 1.0 of the tutorial
In part 0.2, I will explain the C# software (Microsoft Visual C# 2010 Express – the evaluation version you can get for free.) and how to use it to start writing programs.