Convert.ToHexString Method

Definition

Overloads

ToHexString(ReadOnlySpan<Byte>)

Converts a span of 8-bit unsigned integers to its equivalent string representation that is encoded with uppercase hex characters.

ToHexString(Byte[], Int32, Int32)

Converts a subset of an array of 8-bit unsigned integers to its equivalent string representation that is encoded with uppercase hex characters. Parameters specify the subset as an offset in the input array and the number of elements in the array to convert.

ToHexString(Byte[])

Converts an array of 8-bit unsigned integers to its equivalent string representation that is encoded with uppercase hex characters.

ToHexString(ReadOnlySpan<Byte>)

Source:
Convert.cs
Source:
Convert.cs
Source:
Convert.cs

Converts a span of 8-bit unsigned integers to its equivalent string representation that is encoded with uppercase hex characters.

C#
public static string ToHexString (ReadOnlySpan<byte> bytes);

Parameters

bytes
ReadOnlySpan<Byte>

A span of 8-bit unsigned integers.

Returns

The string representation in hex of the elements in bytes.

Exceptions

bytes is too large to be encoded.

Applies to

.NET 9 and other versions
Product Versions
.NET 5, 6, 7, 8, 9

ToHexString(Byte[], Int32, Int32)

Source:
Convert.cs
Source:
Convert.cs
Source:
Convert.cs

Converts a subset of an array of 8-bit unsigned integers to its equivalent string representation that is encoded with uppercase hex characters. Parameters specify the subset as an offset in the input array and the number of elements in the array to convert.

C#
public static string ToHexString (byte[] inArray, int offset, int length);

Parameters

inArray
Byte[]

An array of 8-bit unsigned integers.

offset
Int32

An offset in inArray.

length
Int32

The number of elements of inArray to convert.

Returns

The string representation in hex of length elements of inArray, starting at position offset.

Exceptions

inArray is null.

offset or length is negative.

offset plus length is greater than the length of inArray.

inArray is too large to be encoded.

Applies to

.NET 9 and other versions
Product Versions
.NET 5, 6, 7, 8, 9

ToHexString(Byte[])

Source:
Convert.cs
Source:
Convert.cs
Source:
Convert.cs

Converts an array of 8-bit unsigned integers to its equivalent string representation that is encoded with uppercase hex characters.

C#
public static string ToHexString (byte[] inArray);

Parameters

inArray
Byte[]

An array of 8-bit unsigned integers.

Returns

The string representation in hex of the elements in inArray.

Exceptions

inArray is null.

inArray is too large to be encoded.

Applies to

.NET 9 and other versions
Product Versions
.NET 5, 6, 7, 8, 9