EDIT: C# and C#.NET is the same thing
C was the origin of the C-family of language. It was designed as system programming language (for writing OS kernels, drivers, compilers, etc), though it is also often used to write portable applications. C1X is the planned update to C.
C++ is C with objects; C is originally a procedural language. C++ brings OOP into C-family of language, it includes classes, operator overload, etc and a new set of standard libraries for working with classes while trying to be backward compatible with C. C++0x is the planned update for C++.
C# is a rotten apple. It is developed by Microsoft to run on top of the .NET framework CLR. IMO C# is more similar to Java than C/C++, and the only similarity to C/C++ is the name. C# program only run on Windows since .NET framework runs only on Windows and non-Microsoft implementations has unclear legal status (see Wikipedia under criticism).
Let's have a taste of each language:
/* imports in C is based on preprocessor, it simply inserts
รโ** the content of the imported file to the source */
#include <stdio.h>
int main() {
รโ*รโ*int var;
รโ*รโ*
รโ*รโ*/* one of the main criticism of C is scanf/printf is not type-safe
รโ*รโ*รโ** imagine what would happen if I used the wrong format code */
รโ*รโ*scanf("%d", var);
รโ*รโ*printf("Hello World %d\n", 10);
รโ*รโ*
รโ*รโ*/* the return value of main() becomes the program's return code */
รโ*รโ*return 0;
}
C++
/* imports in C++ is also based on preprocessor, iostream is a new type-safe
รโ** object oriented input/output mechanism in C */
#include <iostream>
/* C++ has classes, it introduces namespaces;
รโ** the cin/cout object is inside the std namespace,
รโ** without using we'll have to refer cin/cout by their
รโ** fully qualified name (std::cin and std::cout) */
using namespace std;
int main() {
รโ*รโ*int var;
รโ*รโ*
รโ*รโ*/* No format code, C++'s cin/cout is type safe and powerful;
รโ*รโ*รโ** also note the use of << and >> which is a binary
รโ*รโ*รโ** bit-shift operator this demonstrates C++ operator overloading */
รโ*รโ*cin >> var;
รโ*รโ*cout << "Hello World " << var << endl;
รโ*รโ*
รโ*รโ*return 0;
}
C#:
/* import in C# is NOT a preprocessor macro, it's similar to Java's import */
using System;
/* C++ introduces classes, but it doesn't *require* you to write
รโ** everything in class cause C++ is a multi-paradigm language;
รโ** C# is like Java requires the main() to be in a class */
class ExampleClass {
รโ*รโ*/* main() is lowercase in C and C++, C# for no apparent reason
รโ*รโ*changes the convention. */
รโ*รโ*static void Main() {
รโ*รโ*รโ*รโ*string input;
รโ*รโ*รโ*รโ*int var;
รโ*รโ*รโ*รโ*/* Just like Java, you can only read string from stdin
รโ*รโ*รโ*รโ*รโ** and have to manually convert using int.Parse
รโ*รโ*รโ*รโ*รโ** (similar to Java's Integer.parseInt)*/
รโ*รโ*รโ*รโ*input = Console.ReadLine();
รโ*รโ*รโ*รโ*var = int.Parse(input);
รโ*รโ*รโ*รโ*
รโ*รโ*รโ*รโ*/* remember how I told you C# is more like Java? Printing string
รโ*รโ*รโ*รโ*รโ** is a call to System.out.printLine() in Java, looks familiar?
รโ*รโ*รโ*รโ*รโ** Console.WriteLine is an overloaded function only allowing one
รโ*รโ*รโ*รโ*รโ** argument to be passed to it, just like Java's */
รโ*รโ*รโ*รโ*Console.WriteLine("Hello, world!");
รโ*รโ*}
}
Although some of the design decision of C# is arguably better than C++, C# largely deviates from the design goal of C/C++ which aims to err on the side of machine efficiency. C# is, like Java, designed to run on top of a Virtual Machine (bytecode interpreter), C/C++ is designed to be compiled into native machine code which makes it fast.
Learn C if you want to write portable program in a mid-level language (high-level language isn't suitable for writing system program, low-level assembly language is not portable; C is the best mid-ground). Learn C++ if you want to use OOP using C-like syntax. Learn C# if you want to get tangled in Microsoft-ism.