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
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
Remarks
EncodingOptions will be initialized with DefaultPreambleSequence and DefaultEncoding.
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
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)
public static bool TryDetectUnicodeEncoding(this byte[] bytes, out Encoding result)
Parameters
bytes
Byte[]The byte[] to extend.
result
EncodingWhen 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 thebytes
parameter is null, or does not contain a Unicode representation of an Encoding.
Returns
- Boolean
true
if thebytes
parameter was converted successfully; otherwise,false
.