System.Runtime.InteropServices.Marshal.ReadInt32 Method

Reads a 32-bit signed integer at a given offset from unmanaged memory.

Syntax

[System.Runtime.ConstrainedExecution.ReliabilityContract(System.Runtime.ConstrainedExecution.Consistency.WillNotCorruptState, System.Runtime.ConstrainedExecution.Cer.Success)]
public static int ReadInt32 (IntPtr ptr, int ofs)

Parameters

ptr
The base address in unmanaged memory from which to read.
ofs
An additional byte offset, which is added to the ptr parameter before reading.

Returns

The 32-bit signed integer read from unmanaged memory.

Remarks

Marshal.ReadInt32(object, int) enables direct interaction with an unmanaged 32-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 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