Good Resources

C# FAQ for C++ programmers

Some Key Differences

Classes and structs

Classes and structs are almost the same in C++ – this is not true for C#.  In C#, structs are value types (instances stored directly on the stack, or inline within heap-based objects), whereas classes are reference types (instances stored on the heap, accessed indirectly via a reference). Also structs cannot inherit from structs or classes, though they can implement interfaces. Structs cannot have destructors. A C# struct is much more like a C struct than a C++ struct.

Memory types

Chars and strings in .NET are 16-bit (Unicode/UTF-16), not 8-bit like C++

#include

There is no '#include' statement – use "using" instead.  See here.

#define

There is no '#define' statement – use const instead.  See here.

Header Files (*.h)

Nope, not used in C#.  See here.

Using C++ code with C#

Where existing C++ code must be used with a new application, the existing code can be wrapped using C++/CLI to allow it to interop with C#.

USEFUL?
We benefit hugely from resources on the web so we decided we should try and give back some of our knowledge and resources to the community by opening up many of our company’s internal notes and libraries through mini sites like this. We hope you find the site helpful.
Please feel free to comment if you can add help to this page or point out issues and solutions you have found, but please note that we do not provide support on this site. If you need help with a problem please use one of the many online forums.