System.Runtime.InteropServices.Marshal.WriteInt16 Method

Writes a 16-bit signed integer value to unmanaged memory at a specified offset.

Syntax

public static void WriteInt16 (object ptr, int ofs, char val)

Parameters

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

Remarks

Marshal.WriteInt16(IntPtr, int, short) enables direct interaction with an unmanaged 16-bit signed 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