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 for importing. The Interop marshaler marshals parameters and returns values between managed and unmanaged memory. Blittable types do not require conversion, but nonblittable types require conversion to unmanaged memory. Developers can marshal nonblittable types explicitly using the MarshalAs attribute.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.226.104.127