Game Development Reference
C# also provides access to the common API styles: COM+, Automation, .NET
Class Framework, and C-style APIs. Also available is an unsafe mode, where point-
ers can be used when you want to manipulate memory that is not under control
of the garbage collector.
The C# language is also an evolution of C++ and Java, and supports many of their
features in the areas of expressions, statements, and operators. As a result, the
learning curve for C# is generally quite rapid due to the comfort level when
migrating from either C++ or Java.
Most game development studios have numerous legacy tools that do not have the
available resources or need to migrate to the .NET platform. Microsoft realizes
that migration does not magically happen overnight, and has provided some
mechanisms to foster interoperability between managed and unmanaged compo-
nents. The interoperability mechanisms permit developers to slowly migrate lega-
cy components into managed applications piece by piece, while allowing them to
build a complete application with a combination of unmanaged and managed
When building new .NET applications, there are provisions for using Win32 DLL
exports and COM objects. There are also provisions for legacy applications to use
a .NET assembly as if it were an ordinary COM object, and provisions to use an
individual routine from a .NET assembly.
In addition to the interoperability mechanisms below, the .NET platform also
includes support for Win32 sockets and Web Services, which can be utilized for
interoperability between managed and unmanaged applications.
Platform Invocation Service (P/Invoke)
Interfacing with C-style functions in native DLLs is offered through the Platform
Invocation Service, also known as P/Invoke, and although both Win32 API rou-
tines and custom exports are supported, the most common distinctive use is for
accessing system routines that are not generally available to .NET developers. For
example, when performing high-accuracy timing, you must use P/Invoke to call
QueryPerformanceCounter and QueryPerformanceFrequency.
There is quite a varying degree of data types for both the Win32 and .NET plat-
forms, and marshaling is required to transform data into the appropriate data