This area of the site is about the Microsoft language C# (C-Sharp). It is intended for those, typically game programming enthusiasts, who already know C++.
This section of the site is currently being added to and will develop more fully over the course of the next few months.
Well firstly it is probably best to ask why not use C#? What are the problems with it? Well firstly it is what Microsoft call a managed language in that it does not compile down to native code. This means that on each supported platform there must be a kind of virtual machine that translates the C# code as required at runtime. It is very like Java in this way. Of course the problem with this is speed. It will never be able to run as fast as a native language like C++.
For games development C# is not really fast enough for the latest demanding games. However for less demanding games requiring rapid development it could be very useful. Currently it is not widely used in the games industry for game development however it is being used quite extensively for tool development. Note that C# can interface with native language binaries via its interop capabilities.
The great advantage to C# is that it promotes rapid development. It is very easy and quick to knock up a game tool or even a game demo using the XNA additions. It is also a real joy to develop with (I spent some time last summer learning it and found it really easy to work with and with a lot of very nice features that I now miss when going back to C++ programming). Being a managed language and a new language it integrates into Visual Studio in ways that native languages cannot hope to. Intellisense finally works properly! Refactoring is even built in and there are many other useful tools to aid development.
As this site is mainly dedicated to C++ programming I am assuming you already know how to program in C++ (or some other object oriented language) but are interested in trying out some C#. Therefore I will concentrate on C# from a C++ programmers perspective.
An awful lot of C# is very familiar to a C++ programmer but some of the first things you will notice in C# as being different to C++ are
Other less obvious differences are
It can be confusing to start with for a C++ programmer using C# to know when something is a reference or not. Basically all language types like int, float, bool etc. are not references and are used just like they are in C++. They also go on the stack like in C++. If you pass them to a function a copy is made (like in C++). If you do want to change them in the function you would need to use the ref keyword in the function definition and when calling the function. Class instances are references and must be created using new and are put on the stack and may be null. If you pass them to a function the function can alter the instance data but not the reference itself - no copy of the instance data is made. So thinking in C++ terms all class instance variables are pointers while all language types are not.
Slightly confusingly structures are treated just like language types and go on the stack (even when created with new). This is quite different to C++ where a structure is basically a class with all public data.
class Player
{
public int Health { get; set; }
}
One of the greatest features of C# is the huge number of libraries it comes with. These support all sorts of operations and are very well designed. An example is every type has a "ToString" member function allowing it to be converted to a string. In C++ this must be done by creating specific functionality (see string handling). In C# you can simply write "The value of a is "+a.ToString();
Useful library types include
To use libraries you state you want them via the 'using' keyword like in C++ where you include names from a namespace.