Class BitConverterEx
Provides methods for converting between decimal, Int128, UInt128 and their corresponding byte representations. This class supplements BitConverter with conversions not natively supported.
public static class BitConverterEx
- Inheritance
-
BitConverterEx
- Inherited Members
Methods
GetBytes(decimal)
Converts the specified decimal value into its 16-byte binary representation.
public static byte[] GetBytes(decimal d)
Parameters
Returns
GetBytes(Int128)
Converts an Int128 value into its 16-byte binary representation.
public static byte[] GetBytes(Int128 i)
Parameters
Returns
GetBytes(UInt128)
Converts a UInt128 value into its 16-byte binary representation.
public static byte[] GetBytes(UInt128 i)
Parameters
Returns
ToDecimal(ReadOnlySpan<byte>)
Converts a 16-byte ReadOnlySpan<T> of bytes into a decimal.
public static decimal ToDecimal(ReadOnlySpan<byte> bytes)
Parameters
bytesReadOnlySpan<byte>A read-only span of at least 16 bytes that contains the binary representation of a decimal value.
Returns
Exceptions
- ArgumentException
Thrown if
bytesdoes not contain exactly 16 bytes.
ToInt128(ReadOnlySpan<byte>)
Converts a 16-byte ReadOnlySpan<T> of bytes into an Int128.
public static Int128 ToInt128(ReadOnlySpan<byte> bytes)
Parameters
bytesReadOnlySpan<byte>A read-only span of exactly 16 bytes that contains the binary representation of an Int128 value.
Returns
Exceptions
- ArgumentException
Thrown if
bytesdoes not contain exactly 16 bytes.
ToUInt128(ReadOnlySpan<byte>)
Converts a 16-byte ReadOnlySpan<T> of bytes into a UInt128.
public static UInt128 ToUInt128(ReadOnlySpan<byte> bytes)
Parameters
bytesReadOnlySpan<byte>A read-only span of exactly 16 bytes that contains the binary representation of a UInt128 value.
Returns
Exceptions
- ArgumentException
Thrown if
bytesdoes not contain exactly 16 bytes.