Summary

Although pointers are not normally available in C#, developers can choose to use them at their discretion. Pointers are available in the context of unsafe code, which requires the unsafe keyword. You can create pointers to unmanaged types, such as the int, float, and char types. In addition, unsafe code must be compiled with the unsafe compiler option.

You cannot create pointers to managed memory. Managed memory is movable and managed by the Garbage Collector. The fixed statement pins managed memory within a block. Pinned memory is fixed. While pinned, that memory is not accessible to the Garbage Collector.

DllImportAttribute, which describes an unmanaged function that is exported from a library, has various options to configure a function ...

Get Programming Microsoft® Visual C#® 2008: The Language now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.