Table of Contents

Class ByteExtensions

Namespace
Cuemon.Extensions
Assembly
Cuemon.Extensions.Core.dll

Extension methods for the Byte struct.

public static class ByteExtensions
Inheritance
ByteExtensions

Methods

ToBase64String(Byte[])

Converts an array of 8-bit unsigned integers to its equivalent string representation that is encoded with base-64 digits.

public static string ToBase64String(this byte[] bytes)

Parameters

bytes Byte[]

The byte[] to extend.

Returns

String

The string representation, in base 64, of the contents of bytes.

ToBinaryString(Byte[])

Converts the specified bytes to its equivalent binary representation.

public static string ToBinaryString(this byte[] bytes)

Parameters

bytes Byte[]

The byte[] to extend.

Returns

String

A binary String representation of the elements in bytes.

Exceptions

ArgumentNullException

bytes is null.

ToEncodedString(Byte[], Action<EncodingOptions>)

Converts the specified bytes to a string using the provided preferred encoding.

public static string ToEncodedString(this byte[] bytes, Action<EncodingOptions> setup = null)

Parameters

bytes Byte[]

The byte[] to extend.

setup Action<EncodingOptions>

The EncodingOptions which need to be configured.

Returns

String

A String containing the results of decoding the specified sequence of bytes.

Remarks

ToHexadecimalString(Byte[])

Converts the specified bytes to its equivalent hexadecimal representation.

public static string ToHexadecimalString(this byte[] bytes)

Parameters

bytes Byte[]

The byte[] to extend.

Returns

String

A hexadecimal String representation of the elements in bytes.

Exceptions

ArgumentNullException

bytes is null.

ToUrlEncodedBase64String(Byte[])

Encodes a byte array into its equivalent string representation using base 64 digits, which is usable for transmission on the URL.

public static string ToUrlEncodedBase64String(this byte[] bytes)

Parameters

bytes Byte[]

The byte[] to extend.

Returns

String

The string containing the encoded token if the byte array length is greater than one; otherwise, an empty string ("").

TryDetectUnicodeEncoding(Byte[], out Encoding)

Tries to resolve the Unicode Encoding object from the specified Byte array.

public static bool TryDetectUnicodeEncoding(this byte[] bytes, out Encoding result)

Parameters

bytes Byte[]

The byte[] to extend.

result Encoding

When this method returns, it contains the Unicode Encoding value equivalent to the encoding contained in bytes, if the conversion succeeded, or a null reference (Nothing in Visual Basic) if the conversion failed. The conversion fails if the bytes parameter is null, or does not contain a Unicode representation of an Encoding.

Returns

Boolean

true if the bytes parameter was converted successfully; otherwise, false.