Windows Dev Center

Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

BitConverter.ToInt32 Method

Returns a 32-bit signed integer converted from four bytes at a specified position in a byte array.

Namespace:  System
Assemblies:   System.Runtime.Extensions (in System.Runtime.Extensions.dll)
  mscorlib (in mscorlib.dll)

static member ToInt32 : 
        value:byte[] * 
        startIndex:int -> int

Parameters

value
Type: System.Byte[]

An array of bytes.

startIndex
Type: System.Int32

The starting position within value.

Return Value

Type: System.Int32
A 32-bit signed integer formed by four bytes beginning at startIndex.

ExceptionCondition
ArgumentException

startIndex is greater than or equal to the length of value minus 3, and is less than or equal to the length of value minus 1.

ArgumentNullException

value is a null reference (Nothing in Visual Basic).

ArgumentOutOfRangeException

startIndex is less than zero or greater than the length of value minus 1.

The ToInt32 method converts the bytes from index startIndex to startIndex + 3 to an Int32 value. The order of bytes in the array must reflect the endianness of the computer system's architecture; for more information, see the Remarks section of BitConverter.

The following example uses the ToInt32 method to create Int32 values from a four-byte array and from the upper four bytes of an eight-byte array. It also uses the GetBytes(Int32) and ToInt32 methods to round-trip an Int32 value.

No code example is currently available or this language may not be supported.

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0, 1.1

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

XNA Framework

Supported in: 3.0, 2.0, 1.0

Portable Class Library

Supported in: Portable Class Library

Supported in: Windows Phone 8.1

Supported in: Windows Phone Silverlight 8.1

Supported in: Windows Phone Silverlight 8
Show:
© 2015 Microsoft