Class BinaryPrimitives
Reads bytes as primitives with specific endianness.
Inherited Members
Namespace: System.Buffers.Binary
Assembly: System.Buffers.Binary.BinaryPrimitives.dll
Syntax
public static class BinaryPrimitives
Methods
| Improve this Doc View SourceReadInt16BigEndian(SpanByte)
Reads an System.Int16 from the beginning of a read-only span of bytes, as big endian.
Declaration
public static short ReadInt16BigEndian(SpanByte source)
Parameters
Type | Name | Description |
---|---|---|
SpanByte | source | The read-only span to read. |
Returns
Type | Description |
---|---|
Int16 | The big endian value. |
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException | Source is too small to contain an System.Int16. |
ReadInt16LittleEndian(SpanByte)
Reads an System.Int16 from the beginning of a read-only span of bytes, as little endian.
Declaration
public static short ReadInt16LittleEndian(SpanByte source)
Parameters
Type | Name | Description |
---|---|---|
SpanByte | source | The read-only span to read. |
Returns
Type | Description |
---|---|
Int16 | The little endian value. |
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException | Source is too small to contain an System.Int16. |
ReadInt32BigEndian(SpanByte)
Reads an System.Int32 from the beginning of a read-only span of bytes, as big endian.
Declaration
public static int ReadInt32BigEndian(SpanByte source)
Parameters
Type | Name | Description |
---|---|---|
SpanByte | source | The read-only span to read. |
Returns
Type | Description |
---|---|
Int32 | The big endian value. |
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException | Source is too small to contain an System.Int32. |
ReadInt32LittleEndian(SpanByte)
Reads an System.Int32 from the beginning of a read-only span of bytes, as little endian.
Declaration
public static int ReadInt32LittleEndian(SpanByte source)
Parameters
Type | Name | Description |
---|---|---|
SpanByte | source | The read-only span to read. |
Returns
Type | Description |
---|---|
Int32 | The little endian value. |
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException | Source is too small to contain an System.Int32. |
ReadInt64BigEndian(SpanByte)
Reads an System.Int64 from the beginning of a read-only span of bytes, as little endian.
Declaration
public static long ReadInt64BigEndian(SpanByte source)
Parameters
Type | Name | Description |
---|---|---|
SpanByte | source | The read-only span to read. |
Returns
Type | Description |
---|---|
Int64 | The little endian value. |
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException | Source is too small to contain an System.Int64. |
ReadInt64LittleEndian(SpanByte)
Reads an System.Int64 from the beginning of a read-only span of bytes, as big endian.
Declaration
public static long ReadInt64LittleEndian(SpanByte source)
Parameters
Type | Name | Description |
---|---|---|
SpanByte | source | The read-only span to read. |
Returns
Type | Description |
---|---|
Int64 | The big endian value. |
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException | Source is too small to contain an System.Int64. |
ReadSingleBigEndian(SpanByte)
Reads a Single from the beginning of a read-only span of bytes, as big endian.
Declaration
public static float ReadSingleBigEndian(SpanByte source)
Parameters
Type | Name | Description |
---|---|---|
SpanByte | source | The read-only span to read. |
Returns
Type | Description |
---|---|
Single | The big endian value. |
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException | Source is too small to contain a Single. |
ReadSingleLittleEndian(SpanByte)
Reads a Single from the beginning of a read-only span of bytes, as little endian.
Declaration
public static float ReadSingleLittleEndian(SpanByte source)
Parameters
Type | Name | Description |
---|---|---|
SpanByte | source | The read-only span to read. |
Returns
Type | Description |
---|---|
Single | The little endian value. |
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException | Source is too small to contain a Single. |
ReadUInt16BigEndian(SpanByte)
Reads a System.UInt16 from the beginning of a read-only span of bytes, as big endian.
Declaration
public static ushort ReadUInt16BigEndian(SpanByte source)
Parameters
Type | Name | Description |
---|---|---|
SpanByte | source | The read-only span to read. |
Returns
Type | Description |
---|---|
UInt16 | The big endian value. |
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException | Source is too small to contain an System.Int16. |
ReadUInt16LittleEndian(SpanByte)
Reads a System.UInt16 from the beginning of a read-only span of bytes, as little endian.
Declaration
public static ushort ReadUInt16LittleEndian(SpanByte source)
Parameters
Type | Name | Description |
---|---|---|
SpanByte | source | The read-only span to read. |
Returns
Type | Description |
---|---|
UInt16 | The little endian value. |
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException | Source is too small to contain an System.Int16. |
ReadUInt32BigEndian(SpanByte)
Reads a System.UInt32 from the beginning of a read-only span of bytes, as big endian.
Declaration
public static uint ReadUInt32BigEndian(SpanByte source)
Parameters
Type | Name | Description |
---|---|---|
SpanByte | source | The read-only span to read. |
Returns
Type | Description |
---|---|
UInt32 | The big endian value. |
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException | Source is too small to contain an System.Int32. |
ReadUInt32LittleEndian(SpanByte)
Reads a System.UInt32 from the beginning of a read-only span of bytes, as little endian.
Declaration
public static uint ReadUInt32LittleEndian(SpanByte source)
Parameters
Type | Name | Description |
---|---|---|
SpanByte | source | The read-only span of bytes to read. |
Returns
Type | Description |
---|---|
UInt32 | The little endian value. |
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException | Source is too small to contain an System.Int32. |
ReadUInt64BigEndian(SpanByte)
Reads a System.UInt64 from the beginning of a read-only span of bytes, as big endian.
Declaration
public static ulong ReadUInt64BigEndian(SpanByte source)
Parameters
Type | Name | Description |
---|---|---|
SpanByte | source | The read-only span of bytes to read. |
Returns
Type | Description |
---|---|
UInt64 | The big endian value. |
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException | Source is too small to contain an System.Int64. |
ReadUInt64LittleEndian(SpanByte)
Reads a System.UInt64 from the beginning of a read-only span of bytes, as little endian.
Declaration
public static ulong ReadUInt64LittleEndian(SpanByte source)
Parameters
Type | Name | Description |
---|---|---|
SpanByte | source | The read-only span of bytes to read. |
Returns
Type | Description |
---|---|
UInt64 | The little endian value. |
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException | Source is too small to contain an System.Int64. |
WriteInt16BigEndian(SpanByte, Int16)
Writes an System.Int16 into a span of bytes, as big endian.
Declaration
public static void WriteInt16BigEndian(SpanByte destination, short value)
Parameters
Type | Name | Description |
---|---|---|
SpanByte | destination | The span of bytes where the value is to be written, as big endian. |
Int16 | value | The value to write into the span of bytes. |
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException | Source is too small to contain an System.Int16. |
WriteInt16LittleEndian(SpanByte, Int16)
Writes an System.Int16 into a span of bytes, as little endian.
Declaration
public static void WriteInt16LittleEndian(SpanByte destination, short value)
Parameters
Type | Name | Description |
---|---|---|
SpanByte | destination | The span of bytes where the value is to be written, as little endian. |
Int16 | value | The value to write into the span of bytes. |
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException | Source is too small to contain an System.Int16. |
WriteInt32BigEndian(SpanByte, Int32)
Writes an System.Int32 into a span of bytes, as big endian.
Declaration
public static void WriteInt32BigEndian(SpanByte destination, int value)
Parameters
Type | Name | Description |
---|---|---|
SpanByte | destination | The span of bytes where the value is to be written, as big endian. |
Int32 | value | The value to write into the span of bytes. |
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException | Source is too small to contain an System.Int32. |
WriteInt32LittleEndian(SpanByte, Int32)
Writes an System.Int32 into a span of bytes, as little endian.
Declaration
public static void WriteInt32LittleEndian(SpanByte destination, int value)
Parameters
Type | Name | Description |
---|---|---|
SpanByte | destination | The span of bytes where the value is to be written, as little endian. |
Int32 | value | The value to write into the span of bytes. |
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException | Source is too small to contain an System.Int32. |
WriteInt64BigEndian(SpanByte, Int64)
Writes an System.Int64 into a span of bytes, as big endian.
Declaration
public static void WriteInt64BigEndian(SpanByte destination, long value)
Parameters
Type | Name | Description |
---|---|---|
SpanByte | destination | The span of bytes where the value is to be written, as big endian. |
Int64 | value | The value to write into the span of bytes. |
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException | Source is too small to contain an System.Int64. |
WriteInt64LittleEndian(SpanByte, Int64)
Writes an System.Int64 into a span of bytes, as little endian.
Declaration
public static void WriteInt64LittleEndian(SpanByte destination, long value)
Parameters
Type | Name | Description |
---|---|---|
SpanByte | destination | The span of bytes where the value is to be written, as little endian. |
Int64 | value | The value to write into the span of bytes. |
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException | Source is too small to contain an System.Int64. |
WriteSingleBigEndian(SpanByte, Single)
Writes a Single into a span of bytes, as big endian.
Declaration
public static void WriteSingleBigEndian(SpanByte destination, float value)
Parameters
Type | Name | Description |
---|---|---|
SpanByte | destination | The span of bytes where the value is to be written, as big endian. |
Single | value | The value to write into the span of bytes. |
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException | Destination is too small to contain a Single. |
WriteSingleLittleEndian(SpanByte, Single)
Writes a Single into a span of bytes, as little endian.
Declaration
public static void WriteSingleLittleEndian(SpanByte destination, float value)
Parameters
Type | Name | Description |
---|---|---|
SpanByte | destination | The span of bytes where the value is to be written, as little endian. |
Single | value | The value to write into the span of bytes. |
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException | Destination is too small to contain a Single. |
WriteUInt16BigEndian(SpanByte, UInt16)
Writes a System.UInt16 into a span of bytes, as big endian.
Declaration
public static void WriteUInt16BigEndian(SpanByte destination, ushort value)
Parameters
Type | Name | Description |
---|---|---|
SpanByte | destination | The span of bytes where the value is to be written, as big endian. |
UInt16 | value | The value to write into the span of bytes. |
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException | Source is too small to contain an System.Int16. |
WriteUInt16LittleEndian(SpanByte, UInt16)
Writes a System.UInt16 into a span of bytes, as little endian.
Declaration
public static void WriteUInt16LittleEndian(SpanByte destination, ushort value)
Parameters
Type | Name | Description |
---|---|---|
SpanByte | destination | The span of bytes where the value is to be written, as little endian. |
UInt16 | value | The value to write into the span of bytes. |
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException | Source is too small to contain an System.Int16. |
WriteUInt32BigEndian(SpanByte, UInt32)
Writes a System.UInt32 into a span of bytes, as big endian.
Declaration
public static void WriteUInt32BigEndian(SpanByte destination, uint value)
Parameters
Type | Name | Description |
---|---|---|
SpanByte | destination | The span of bytes where the value is to be written, as big endian. |
UInt32 | value | The value to write into the span of bytes. |
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException | Source is too small to contain an System.Int32. |
WriteUInt32LittleEndian(SpanByte, UInt32)
Writes a System.UInt32 into a span of bytes, as little endian.
Declaration
public static void WriteUInt32LittleEndian(SpanByte destination, uint value)
Parameters
Type | Name | Description |
---|---|---|
SpanByte | destination | The span of bytes where the value is to be written, as little endian. |
UInt32 | value | The value to write into the span of bytes. |
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException | Source is too small to contain an System.Int32. |
WriteUInt64BigEndian(SpanByte, UInt64)
Writes a System.UInt64 into a span of bytes, as big endian.
Declaration
public static void WriteUInt64BigEndian(SpanByte destination, ulong value)
Parameters
Type | Name | Description |
---|---|---|
SpanByte | destination | The span of bytes where the value is to be written, as big endian. |
UInt64 | value | The value to write into the span of bytes. |
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException | Source is too small to contain an System.Int64. |
WriteUInt64LittleEndian(SpanByte, UInt64)
Writes a System.UInt64 into a span of bytes, as little endian.
Declaration
public static void WriteUInt64LittleEndian(SpanByte destination, ulong value)
Parameters
Type | Name | Description |
---|---|---|
SpanByte | destination | The span of bytes where the value is to be written, as little endian. |
UInt64 | value | The value to write into the span of bytes. |
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException | Source is too small to contain an System.Int64. |