Game Development Reference
Code and Pointers
At some point you have to decide whether you're going to be a politician or
an engineer. You cannot be both. To be a politician is to champion perception
over reality. To be an engineer is to make perception subservient to reality.
They are opposites. You can't do both simultaneously.
H. W. Kenton
One of the best features of .NET is the automatic memory management provided
by the Common Language Runtime, reference types, and the Garbage Collector. C#
hides most of its memory management, which makes life a lot easier for developers.
In almost all situations, this censorship from the nitty gritty details of memory
management is a good thing, though the need does arise when low-level access to
memory is needed.
Memory in C++ is accessed and managed through the use of pointers. C# supports
the concept of pointers, but only when absolutely necessary. The use of pointers in
C# is discouraged, though there are a few rare situations that require them.
These situations are:
When dealing with existing structures on disk, or when you need direct
access to memory.
When using Platform Invoke or Advanced COM that involve structures
with pointers in them.
When there is a strong need for performance-critical code, such as applications
that require enhanced performance to make things as “real time” as possible.