ToString Method (Byte[], Int32)
Collapse the table of content
Expand the table of content

BitConverter.ToString Method (Byte[], Int32)

Converts the numeric value of each element of a specified subarray of bytes to its equivalent hexadecimal string representation.

Namespace:  System
Assembly:  mscorlib (in mscorlib.dll)

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


Type: System.Byte[]
An array of bytes.
Type: System.Int32
The starting position within value.

Return Value

Type: System.String
A string of hexadecimal pairs separated by hyphens, where each pair represents the corresponding element in a subarray of value; for example, "7F-2C-4A-00".


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


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

The elements from array position startIndex to the end of the array are converted. The order of hexadecimal strings returned by the ToString method depends on whether the computer architecture is little-endian or big-endian.

The following code example converts the part of a Byte array starting at the specified startIndex to a String with the ToString method.

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

.NET Framework

Supported in: 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Portable Class Library

Supported in: Portable Class Library

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Community Additions

© 2016 Microsoft