Class ByteConverterExtensions
This is an extension implementation of the ByteConverter class.
Inheritance
Namespace: Cuemon
Assembly: Cuemon.Core.dll
Syntax
public static class ByteConverterExtensions
Methods
| Improve this DocFromUrlEncodedBase64(String)
Decodes a URL string token to its equivalent byte array using base 64 digits.
Declaration
public static byte[] FromUrlEncodedBase64(this string value)
Parameters
Type | Name | Description |
---|---|---|
System.String | value | The URL string token to decode. |
Returns
Type | Description |
---|---|
System.Byte[] | The byte array containing the decoded URL string token. |
ToByteArray(Stream)
Converts the specified value
to a byte array always starting from position 0 (when supported).
Declaration
public static byte[] ToByteArray(this Stream value)
Parameters
Type | Name | Description |
---|---|---|
System.IO.Stream | value | The System.IO.Stream value to be converted. |
Returns
Type | Description |
---|---|
System.Byte[] | A byte array containing the data from the stream. |
ToByteArray(Stream, Boolean)
Converts the specified value
to a byte array.
Declaration
public static byte[] ToByteArray(this Stream value, bool leaveStreamOpen)
Parameters
Type | Name | Description |
---|---|---|
System.IO.Stream | value | The System.IO.Stream value to be converted. |
System.Boolean | leaveStreamOpen | if |
Returns
Type | Description |
---|---|
System.Byte[] | A byte array containing the data from the stream. |
ToByteArray(String)
Converts the specified value
to a byte array using DefaultEncoding for the encoding and DefaultPreambleSequence for any preamble sequences.
Declaration
public static byte[] ToByteArray(this string value)
Parameters
Type | Name | Description |
---|---|---|
System.String | value | The string to be converted. |
Returns
Type | Description |
---|---|
System.Byte[] | A byte array containing the results of encoding the specified set of characters. |
ToByteArray(String, Action<EncodingOptions>)
Converts the specified value
to a byte array using the provided preferred encoding.
Declaration
public static byte[] ToByteArray(this string value, Action<EncodingOptions> setup)
Parameters
Type | Name | Description |
---|---|---|
System.String | value | The string to be converted. |
System.Action<EncodingOptions> | setup | The EncodingOptions which need to be configured. |
Returns
Type | Description |
---|---|
System.Byte[] | A byte array containing the results of encoding the specified set of characters. |
Remarks
EncodingOptions will be initialized with DefaultPreambleSequence and DefaultEncoding.
ToByteArray<T>(T)
Converts the specified value
to an array of bytes.
Declaration
public static byte[] ToByteArray<T>(this T value)
where T : struct, IConvertible
Parameters
Type | Name | Description |
---|---|---|
T | value | The System.IConvertible value to convert. |
Returns
Type | Description |
---|---|
System.Byte[] | An array of bytes equivalent to the data of the |
Type Parameters
Name | Description |
---|---|
T |
Exceptions
Type | Condition |
---|---|
System.ArgumentOutOfRangeException |
|
ToByteArray<T>(IEnumerable<T>)
Converts the specified sequence of values
to an array of bytes.
Declaration
public static byte[] ToByteArray<T>(this IEnumerable<T> values)
where T : struct, IConvertible
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<T> | values | A sequence of System.IConvertible values to convert. |
Returns
Type | Description |
---|---|
System.Byte[] | An array of bytes equivalent to the sequence of the |
Type Parameters
Name | Description |
---|---|
T |
Exceptions
Type | Condition |
---|---|
System.ArgumentOutOfRangeException |
|
System.ArgumentNullException |
|