System.Runtime.InteropServices.Marshal.ReadInt16 Method

Reads a 16-bit signed integer from unmanaged memory.

Syntax

public static short ReadInt16 (IntPtr ptr)

Parameters

ptr
The address in unmanaged memory from which to read.

Returns

The 16-bit signed integer read from unmanaged memory.

Remarks

Marshal.ReadInt16(object, int) has an implied offset of 0. This method enables direct interaction with an unmanaged C-style Int16 array, eliminating the expense of copying an entire unmanaged array (using Marshal.Copy(Int32[], int, IntPtr, int)) to a separate managed array before reading its element values.

Reading from 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