Table of Contents

GetBytes Method

Definition

Namespace
Cuemon
Assemblies
Cuemon.Kernel.dll
Source
src/Cuemon.Kernel/Convertible.cs

GetBytes(IConvertible, Action<ConvertibleOptions>)

Converts the specified IConvertible value to its byte array representation.

public static byte[] GetBytes(IConvertible input, Action<ConvertibleOptions> setup = null)

Parameters

input IConvertible

The value to convert.

setup Action<ConvertibleOptions>

The delegate that configures the conversion options.

Returns

byte[]

A byte array that represents input.

Remarks

Returns the byte representation of NullValue when input is null. Custom converters may be registered globally with RegisterConvertible<T>(Func<T, byte[]>) or supplied locally through Converters.

Exceptions

ArgumentOutOfRangeException

input is of a type for which no converter has been registered or configured.

GetBytes(IEnumerable<IConvertible>, Action<ConvertibleOptions>)

Converts the specified sequence of IConvertible values to a single aggregated byte array.

public static byte[] GetBytes(IEnumerable<IConvertible> input, Action<ConvertibleOptions> setup = null)

Parameters

input IEnumerable<IConvertible>

The sequence of values to convert.

setup Action<ConvertibleOptions>

The delegate that configures the conversion options.

Returns

byte[]

A byte array containing the concatenated byte representations of the elements in input.

GetBytes(bool, Action<EndianOptions>)

Converts the specified bool value to its byte array representation.

public static byte[] GetBytes(bool input, Action<EndianOptions> setup = null)

Parameters

input bool

The value to convert.

setup Action<EndianOptions>

The delegate that configures the byte order.

Returns

byte[]

A byte array that represents input.

GetBytes(byte, Action<EndianOptions>)

Converts the specified byte value to its byte array representation.

public static byte[] GetBytes(byte input, Action<EndianOptions> setup = null)

Parameters

input byte

The value to convert.

setup Action<EndianOptions>

The delegate that configures the byte order.

Returns

byte[]

A byte array that represents input.

GetBytes(char, Action<EndianOptions>)

Converts the specified char value to its byte array representation.

public static byte[] GetBytes(char input, Action<EndianOptions> setup = null)

Parameters

input char

The value to convert.

setup Action<EndianOptions>

The delegate that configures the byte order.

Returns

byte[]

A byte array that represents input.

GetBytes(DateTime)

Converts the specified DateTime value to its byte array representation.

public static byte[] GetBytes(DateTime input)

Parameters

input DateTime

The value to convert.

Returns

byte[]

A byte array that represents input.

Remarks

The value is formatted using the universal sortable date and time pattern and encoded with ASCII.

GetBytes(DBNull)

Converts the specified DBNull value to its byte array representation.

public static byte[] GetBytes(DBNull input)

Parameters

input DBNull

The value to convert.

Returns

byte[]

A byte array representing NullValue.

GetBytes(decimal)

Converts the specified decimal value to its byte array representation.

public static byte[] GetBytes(decimal input)

Parameters

input decimal

The value to convert.

Returns

byte[]

A byte array that represents input.

Remarks

The value is formatted using the invariant culture and encoded with ASCII.

GetBytes(double, Action<EndianOptions>)

Converts the specified double value to its byte array representation.

public static byte[] GetBytes(double input, Action<EndianOptions> setup = null)

Parameters

input double

The value to convert.

setup Action<EndianOptions>

The delegate that configures the byte order.

Returns

byte[]

A byte array that represents input.

GetBytes(short, Action<EndianOptions>)

Converts the specified short value to its byte array representation.

public static byte[] GetBytes(short input, Action<EndianOptions> setup = null)

Parameters

input short

The value to convert.

setup Action<EndianOptions>

The delegate that configures the byte order.

Returns

byte[]

A byte array that represents input.

GetBytes(int, Action<EndianOptions>)

Converts the specified int value to its byte array representation.

public static byte[] GetBytes(int input, Action<EndianOptions> setup = null)

Parameters

input int

The value to convert.

setup Action<EndianOptions>

The delegate that configures the byte order.

Returns

byte[]

A byte array that represents input.

GetBytes(long, Action<EndianOptions>)

Converts the specified long value to its byte array representation.

public static byte[] GetBytes(long input, Action<EndianOptions> setup = null)

Parameters

input long

The value to convert.

setup Action<EndianOptions>

The delegate that configures the byte order.

Returns

byte[]

A byte array that represents input.

GetBytes(sbyte, Action<EndianOptions>)

Converts the specified sbyte value to its byte array representation.

public static byte[] GetBytes(sbyte input, Action<EndianOptions> setup = null)

Parameters

input sbyte

The value to convert.

setup Action<EndianOptions>

The delegate that configures the byte order.

Returns

byte[]

A byte array that represents input.

GetBytes(float, Action<EndianOptions>)

Converts the specified float value to its byte array representation.

public static byte[] GetBytes(float input, Action<EndianOptions> setup = null)

Parameters

input float

The value to convert.

setup Action<EndianOptions>

The delegate that configures the byte order.

Returns

byte[]

A byte array that represents input.

GetBytes(ushort, Action<EndianOptions>)

Converts the specified ushort value to its byte array representation.

public static byte[] GetBytes(ushort input, Action<EndianOptions> setup = null)

Parameters

input ushort

The value to convert.

setup Action<EndianOptions>

The delegate that configures the byte order.

Returns

byte[]

A byte array that represents input.

GetBytes(uint, Action<EndianOptions>)

Converts the specified uint value to its byte array representation.

public static byte[] GetBytes(uint input, Action<EndianOptions> setup = null)

Parameters

input uint

The value to convert.

setup Action<EndianOptions>

The delegate that configures the byte order.

Returns

byte[]

A byte array that represents input.

GetBytes(ulong, Action<EndianOptions>)

Converts the specified ulong value to its byte array representation.

public static byte[] GetBytes(ulong input, Action<EndianOptions> setup = null)

Parameters

input ulong

The value to convert.

setup Action<EndianOptions>

The delegate that configures the byte order.

Returns

byte[]

A byte array that represents input.

GetBytes(string, Action<EncodingOptions>)

Converts the specified string value to its byte array representation.

public static byte[] GetBytes(string input, Action<EncodingOptions> setup = null)

Parameters

input string

The value to convert.

setup Action<EncodingOptions>

The delegate that configures the encoding behavior.

Returns

byte[]

A byte array that represents input.

Remarks

Exceptions

ArgumentNullException

input is null.

InvalidEnumArgumentException

setup configures an invalid value for Preamble.

GetBytes(Enum, Action<EndianOptions>)

Converts the specified Enum value to its underlying byte array representation.

public static byte[] GetBytes(Enum input, Action<EndianOptions> setup = null)

Parameters

input Enum

The value to convert.

setup Action<EndianOptions>

The delegate that configures the byte order.

Returns

byte[]

A byte array that represents the underlying numeric value of input.