This documentation is archived and is not being maintained.


Pointers are special kinds of variables. There are three kinds of pointers supported by the runtime: managed pointers, unmanaged pointers, and unmanaged function pointers.

A managed pointer, also known as a __gc pointer, is a new type of pointer available to managed applications. Managed pointers are references to a managed block of memory from the common language runtime heap. Automatic garbage collection is performed on this heap. Managed pointers are generated for method arguments that are passed by reference. Some languages provide other ways of generating managed pointers. Only managed pointers are CLS-compliant.

An unmanaged pointer is the traditional C++ pointer to an unmanaged block of memory from the standard C++ heap. Because unmanaged pointers are not part of the Common Language Specification (CLS), your language might not provide syntax to define or access these types. See the documentation for your language for information on support for unmanaged pointers.

An unmanaged function pointer is also a traditional C++ pointer that refers to the address of a function. The CLS provides delegates as a managed alternative to unmanaged function pointers.

An explicit definition of a pointer type is not required. All the information necessary to determine the type of a pointer is present when the pointer is declared.

While pointer types are reference types, the value of a pointer type is not an object and you cannot determine the exact type from such a value.

The common type system provides two type-safe operations on pointer types: loading a value from and writing a value to the location referenced by the pointer. These type-safe operations are CLS-compliant.

The common type system also provides three byte-based address arithmetic operations on pointer types: adding integers to and subtracting integers from pointers, and subtracting one pointer from another. The results of the first two arithmetic operations return a value of the same type as the original pointer. These byte-based operations are not CLS-compliant.

See Also

Common Type System | What is the Common Language Specification? | Writing CLS-Compliant Code