System.Runtime.InteropServices.Marshal.WriteIntPtr Method

Writes a processor native-sized integer value to unmanaged memory at a specified offset.

Syntax

public static void WriteIntPtr (IntPtr ptr, int ofs, IntPtr val)

Parameters

ptr
The base address in unmanaged memory to write to.
ofs
An additional byte offset, which is added to the ptr parameter before writing.
val
The value to write.

Remarks

This method writes a 32 bit integer on 32 bit systems, and a 64 bit integer on 64 bit systems.

Marshal.WriteIntPtr(IntPtr, int, IntPtr) enables direct interaction with an unmanaged C-style IntPtr array, eliminating the expense of copying an entire unmanaged array (using Marshal.Copy(Int32[], int, IntPtr, int)) to a separate managed array before setting its element values.

Writing to unaligned memory locations is supported.

Requirements

Namespace: System.Runtime.InteropServices
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0, 4.0.0.0