Class ReadOnlySpanExtensions
- Namespace
- Plugin.ByteArrays
- Assembly
- Plugin.ByteArrays.dll
Functions for working with ReadOnlySpan<byte> providing zero-allocation operations for reading and manipulating byte data.
public static class ReadOnlySpanExtensions
- Inheritance
-
ReadOnlySpanExtensions
- Inherited Members
Methods
EndsWith(ReadOnlySpan<byte>, ReadOnlySpan<byte>)
Determines whether the ReadOnlySpan<byte> ends with the specified pattern. This method is case-sensitive and culture-insensitive.
public static bool EndsWith(this ReadOnlySpan<byte> span, ReadOnlySpan<byte> pattern)
Parameters
spanReadOnlySpan<byte>The span to check.
patternReadOnlySpan<byte>The pattern to check for at the end of the span.
Returns
- bool
True if the span ends with the specified pattern; otherwise, false.
IndexOf(ReadOnlySpan<byte>, ReadOnlySpan<byte>)
Finds the first occurrence of a pattern in a ReadOnlySpan<byte>.
public static int IndexOf(this ReadOnlySpan<byte> span, ReadOnlySpan<byte> pattern)
Parameters
spanReadOnlySpan<byte>The span to search in.
patternReadOnlySpan<byte>The pattern to search for.
Returns
- int
The index of the first occurrence, or -1 if not found.
IsIdenticalTo(ReadOnlySpan<byte>, ReadOnlySpan<byte>)
Checks if two ReadOnlySpan<byte> instances are identical in content and length.
public static bool IsIdenticalTo(this ReadOnlySpan<byte> span1, ReadOnlySpan<byte> span2)
Parameters
span1ReadOnlySpan<byte>First ReadOnlySpan<byte>.
span2ReadOnlySpan<byte>Second ReadOnlySpan<byte>.
Returns
- bool
True if spans are identical; otherwise, false.
StartsWith(ReadOnlySpan<byte>, ReadOnlySpan<byte>)
Checks if a ReadOnlySpan<byte> starts with a specific pattern.
public static bool StartsWith(this ReadOnlySpan<byte> span, ReadOnlySpan<byte> pattern)
Parameters
spanReadOnlySpan<byte>The span to check.
patternReadOnlySpan<byte>The pattern to look for.
Returns
- bool
True if the span starts with the pattern, false otherwise.
ToAsciiString(ReadOnlySpan<byte>, int, int)
Converts parts of a ReadOnlySpan<byte> into an ASCII String.
public static string ToAsciiString(this ReadOnlySpan<byte> span, int position = 0, int numberOfBytesToRead = -1)
Parameters
spanReadOnlySpan<byte>The ReadOnlySpan<byte>.
positionintThe position within the span.
numberOfBytesToReadintNumber of bytes to read. If -1, reads from position to end of span.
Returns
- string
Converted value.
ToAsciiString(ReadOnlySpan<byte>, ref int, int)
Converts parts of a ReadOnlySpan<byte> into an ASCII String.
public static string ToAsciiString(this ReadOnlySpan<byte> span, ref int position, int numberOfBytesToRead = -1)
Parameters
spanReadOnlySpan<byte>The ReadOnlySpan<byte>.
positionintThe position within the span. By reference; is auto-incremented by the size of the output type.
numberOfBytesToReadintNumber of bytes to read. If -1, reads from position to end of span.
Returns
- string
Converted value.
ToAsciiStringOrDefault(ReadOnlySpan<byte>, int, int, string)
Converts parts of a ReadOnlySpan<byte> into an ASCII String.
public static string ToAsciiStringOrDefault(this ReadOnlySpan<byte> span, int position = 0, int numberOfBytesToRead = -1, string defaultValue = "")
Parameters
spanReadOnlySpan<byte>The ReadOnlySpan<byte>.
positionintThe position within the span.
numberOfBytesToReadintNumber of bytes to read. If -1, reads from position to end of span.
defaultValuestringDefault value for that type, can be overridden.
Returns
- string
Converted value.
ToAsciiStringOrDefault(ReadOnlySpan<byte>, ref int, int, string)
Converts parts of a ReadOnlySpan<byte> into an ASCII String.
public static string ToAsciiStringOrDefault(this ReadOnlySpan<byte> span, ref int position, int numberOfBytesToRead = -1, string defaultValue = "")
Parameters
spanReadOnlySpan<byte>The ReadOnlySpan<byte>.
positionintThe position within the span. By reference; is auto-incremented by the size of the output type.
numberOfBytesToReadintNumber of bytes to read. If -1, reads from position to end of span.
defaultValuestringDefault value for that type, can be overridden.
Returns
- string
Converted value.
ToBase64String(ReadOnlySpan<byte>)
Converts the entire ReadOnlySpan<byte> into a Base64 string representation.
public static string ToBase64String(this ReadOnlySpan<byte> span)
Parameters
spanReadOnlySpan<byte>The ReadOnlySpan<byte> to convert.
Returns
- string
A Base64 string representation.
ToBoolean(ReadOnlySpan<byte>, int)
Converts the ReadOnlySpan<byte> into a Boolean value. Size = 1 byte.
public static bool ToBoolean(this ReadOnlySpan<byte> span, int position = 0)
Parameters
spanReadOnlySpan<byte>The ReadOnlySpan<byte>.
positionintThe position within the span.
Returns
- bool
Converted value.
ToBoolean(ReadOnlySpan<byte>, ref int)
Converts the ReadOnlySpan<byte> into a Boolean value. Size = 1 byte.
public static bool ToBoolean(this ReadOnlySpan<byte> span, ref int position)
Parameters
spanReadOnlySpan<byte>The ReadOnlySpan<byte>.
positionintThe position within the span. By reference; is auto-incremented by the size of the output type.
Returns
- bool
Converted value.
ToBooleanOrDefault(ReadOnlySpan<byte>, int, bool)
Converts the ReadOnlySpan<byte> into a Boolean value. Size = 1 byte.
public static bool ToBooleanOrDefault(this ReadOnlySpan<byte> span, int position = 0, bool defaultValue = false)
Parameters
spanReadOnlySpan<byte>The ReadOnlySpan<byte>.
positionintThe position within the span.
defaultValueboolDefault value for that type, can be overridden.
Returns
- bool
Converted value.
ToBooleanOrDefault(ReadOnlySpan<byte>, ref int, bool)
Converts the ReadOnlySpan<byte> into a Boolean value. Size = 1 byte.
public static bool ToBooleanOrDefault(this ReadOnlySpan<byte> span, ref int position, bool defaultValue = false)
Parameters
spanReadOnlySpan<byte>The ReadOnlySpan<byte>.
positionintThe position within the span. By reference; is auto-incremented by the size of the output type.
defaultValueboolValue returned if out of bounds.
Returns
- bool
Converted value.
ToByte(ReadOnlySpan<byte>, int)
Extracts a single byte from the ReadOnlySpan<byte>. Size = 1 byte.
public static byte ToByte(this ReadOnlySpan<byte> span, int position = 0)
Parameters
spanReadOnlySpan<byte>The ReadOnlySpan<byte>.
positionintThe position within the span.
Returns
- byte
The byte value.
ToByte(ReadOnlySpan<byte>, ref int)
Extracts a single byte from the ReadOnlySpan<byte>. Size = 1 byte.
public static byte ToByte(this ReadOnlySpan<byte> span, ref int position)
Parameters
spanReadOnlySpan<byte>The ReadOnlySpan<byte>.
positionintThe position within the span. By reference; is auto-incremented by the size of the output type.
Returns
- byte
The byte value.
ToByteOrDefault(ReadOnlySpan<byte>, int, byte)
Extracts a single byte from the ReadOnlySpan<byte>. Size = 1 byte.
public static byte ToByteOrDefault(this ReadOnlySpan<byte> span, int position = 0, byte defaultValue = 0)
Parameters
spanReadOnlySpan<byte>The ReadOnlySpan<byte>.
positionintThe position within the span.
defaultValuebyteDefault value for that type, can be overridden.
Returns
- byte
The byte value.
ToByteOrDefault(ReadOnlySpan<byte>, ref int, byte)
Extracts a single byte from the ReadOnlySpan<byte>. Size = 1 byte.
public static byte ToByteOrDefault(this ReadOnlySpan<byte> span, ref int position, byte defaultValue = 0)
Parameters
spanReadOnlySpan<byte>The ReadOnlySpan<byte>.
positionintThe position within the span. By reference; is auto-incremented by the size of the output type.
defaultValuebyteValue returned if out of bounds.
Returns
- byte
The byte value.
ToChar(ReadOnlySpan<byte>, int)
Converts the ReadOnlySpan<byte> into a Unicode character. Size = 2 bytes.
public static char ToChar(this ReadOnlySpan<byte> span, int position = 0)
Parameters
spanReadOnlySpan<byte>The ReadOnlySpan<byte>.
positionintThe position within the span.
Returns
- char
Converted value.
ToChar(ReadOnlySpan<byte>, ref int)
Converts the ReadOnlySpan<byte> into a Unicode character. Size = 2 bytes.
public static char ToChar(this ReadOnlySpan<byte> span, ref int position)
Parameters
spanReadOnlySpan<byte>The ReadOnlySpan<byte>.
positionintThe position within the span. By reference; is auto-incremented by the size of the output type.
Returns
- char
Converted value.
ToCharOrDefault(ReadOnlySpan<byte>, int, char)
Converts the ReadOnlySpan<byte> into a Unicode character. Size = 2 bytes.
public static char ToCharOrDefault(this ReadOnlySpan<byte> span, int position = 0, char defaultValue = '\0')
Parameters
spanReadOnlySpan<byte>The ReadOnlySpan<byte>.
positionintThe position within the span.
defaultValuecharDefault value for that type, can be overridden.
Returns
- char
Converted value.
ToCharOrDefault(ReadOnlySpan<byte>, ref int, char)
Converts the ReadOnlySpan<byte> into a Unicode character. Size = 2 bytes.
public static char ToCharOrDefault(this ReadOnlySpan<byte> span, ref int position, char defaultValue = '\0')
Parameters
spanReadOnlySpan<byte>The ReadOnlySpan<byte>.
positionintThe position within the span. By reference; is auto-incremented by the size of the output type.
defaultValuecharValue returned if out of bounds.
Returns
- char
Converted value.
ToDateTime(ReadOnlySpan<byte>, int)
Converts the ReadOnlySpan<byte> into a DateTime value. The DateTime is stored as a 64-bit integer representing ticks. Size = 8 bytes.
public static DateTime ToDateTime(this ReadOnlySpan<byte> span, int position = 0)
Parameters
spanReadOnlySpan<byte>The ReadOnlySpan<byte>.
positionintThe position within the span.
Returns
- DateTime
Converted value.
ToDateTime(ReadOnlySpan<byte>, ref int)
Converts the ReadOnlySpan<byte> into a DateTime value. The DateTime is stored as a 64-bit integer representing ticks. Size = 8 bytes.
public static DateTime ToDateTime(this ReadOnlySpan<byte> span, ref int position)
Parameters
spanReadOnlySpan<byte>The ReadOnlySpan<byte>.
positionintThe position within the span. By reference; is auto-incremented by the size of the output type.
Returns
- DateTime
Converted value.
ToDateTimeFromUnixTimestamp(ReadOnlySpan<byte>, int)
Converts the ReadOnlySpan<byte> into a DateTime from Unix timestamp (seconds since epoch). Size = 4 bytes.
public static DateTime ToDateTimeFromUnixTimestamp(this ReadOnlySpan<byte> span, int position = 0)
Parameters
spanReadOnlySpan<byte>The ReadOnlySpan<byte>.
positionintThe position within the span.
Returns
- DateTime
Converted DateTime value.
ToDateTimeFromUnixTimestamp(ReadOnlySpan<byte>, ref int)
Converts the ReadOnlySpan<byte> into a DateTime from Unix timestamp (seconds since epoch). Size = 4 bytes.
public static DateTime ToDateTimeFromUnixTimestamp(this ReadOnlySpan<byte> span, ref int position)
Parameters
spanReadOnlySpan<byte>The ReadOnlySpan<byte>.
positionintThe position within the span. By reference; is auto-incremented by the size of the output type.
Returns
- DateTime
Converted DateTime value.
ToDateTimeFromUnixTimestampOrDefault(ReadOnlySpan<byte>, int, DateTime)
Converts the ReadOnlySpan<byte> into a DateTime from Unix timestamp (seconds since epoch). Returns the default value if conversion fails. Size = 4 bytes.
public static DateTime ToDateTimeFromUnixTimestampOrDefault(this ReadOnlySpan<byte> span, int position = 0, DateTime defaultValue = default)
Parameters
spanReadOnlySpan<byte>The ReadOnlySpan<byte>.
positionintThe position within the span.
defaultValueDateTimeDefault value for that type, can be overridden.
Returns
- DateTime
Converted DateTime value.
ToDateTimeFromUnixTimestampOrDefault(ReadOnlySpan<byte>, ref int, DateTime)
Converts the ReadOnlySpan<byte> into a DateTime from Unix timestamp (seconds since epoch). Returns the default value if conversion fails. Size = 4 bytes.
public static DateTime ToDateTimeFromUnixTimestampOrDefault(this ReadOnlySpan<byte> span, ref int position, DateTime defaultValue = default)
Parameters
spanReadOnlySpan<byte>The ReadOnlySpan<byte>.
positionintThe position within the span. By reference; is auto-incremented by the size of the output type.
defaultValueDateTimeDefault value for that type, can be overridden.
Returns
- DateTime
Converted DateTime value.
ToDateTimeOffset(ReadOnlySpan<byte>, int)
Converts the ReadOnlySpan<byte> into a DateTimeOffset value. The DateTimeOffset is stored as 10 bytes: 8 bytes for DateTime ticks and 2 bytes for offset minutes. Size = 10 bytes.
public static DateTimeOffset ToDateTimeOffset(this ReadOnlySpan<byte> span, int position = 0)
Parameters
spanReadOnlySpan<byte>The ReadOnlySpan<byte>.
positionintThe position within the span.
Returns
- DateTimeOffset
Converted value.
ToDateTimeOffset(ReadOnlySpan<byte>, ref int)
Converts the ReadOnlySpan<byte> into a DateTimeOffset value. The DateTimeOffset is stored as 10 bytes: 8 bytes for DateTime ticks and 2 bytes for offset minutes. Size = 10 bytes.
public static DateTimeOffset ToDateTimeOffset(this ReadOnlySpan<byte> span, ref int position)
Parameters
spanReadOnlySpan<byte>The ReadOnlySpan<byte>.
positionintThe position within the span. By reference; is auto-incremented by the size of the output type.
Returns
- DateTimeOffset
Converted value.
ToDateTimeOffsetOrDefault(ReadOnlySpan<byte>, int, DateTimeOffset)
Converts the ReadOnlySpan<byte> into a DateTimeOffset value. The DateTimeOffset is stored as 10 bytes: 8 bytes for DateTime ticks and 2 bytes for offset minutes. Size = 10 bytes.
public static DateTimeOffset ToDateTimeOffsetOrDefault(this ReadOnlySpan<byte> span, int position = 0, DateTimeOffset defaultValue = default)
Parameters
spanReadOnlySpan<byte>The ReadOnlySpan<byte>.
positionintThe position within the span.
defaultValueDateTimeOffsetDefault value for that type, can be overridden.
Returns
- DateTimeOffset
Converted value.
ToDateTimeOffsetOrDefault(ReadOnlySpan<byte>, ref int, DateTimeOffset)
Converts the ReadOnlySpan<byte> into a DateTimeOffset value. The DateTimeOffset is stored as 10 bytes: 8 bytes for DateTime ticks and 2 bytes for offset minutes. Size = 10 bytes.
public static DateTimeOffset ToDateTimeOffsetOrDefault(this ReadOnlySpan<byte> span, ref int position, DateTimeOffset defaultValue = default)
Parameters
spanReadOnlySpan<byte>The ReadOnlySpan<byte>.
positionintThe position within the span. By reference; is auto-incremented by the size of the output type.
defaultValueDateTimeOffsetValue returned if out of bounds.
Returns
- DateTimeOffset
Converted value.
ToDateTimeOrDefault(ReadOnlySpan<byte>, int, DateTime)
Converts the ReadOnlySpan<byte> into a DateTime value. The DateTime is stored as a 64-bit integer representing ticks. Size = 8 bytes.
public static DateTime ToDateTimeOrDefault(this ReadOnlySpan<byte> span, int position = 0, DateTime defaultValue = default)
Parameters
spanReadOnlySpan<byte>The ReadOnlySpan<byte>.
positionintThe position within the span.
defaultValueDateTimeDefault value for that type, can be overridden.
Returns
- DateTime
Converted value.
ToDateTimeOrDefault(ReadOnlySpan<byte>, ref int, DateTime)
Converts the ReadOnlySpan<byte> into a DateTime value. The DateTime is stored as a 64-bit integer representing ticks. Size = 8 bytes.
public static DateTime ToDateTimeOrDefault(this ReadOnlySpan<byte> span, ref int position, DateTime defaultValue = default)
Parameters
spanReadOnlySpan<byte>The ReadOnlySpan<byte>.
positionintThe position within the span. By reference; is auto-incremented by the size of the output type.
defaultValueDateTimeValue returned if out of bounds.
Returns
- DateTime
Converted value.
ToDebugString(ReadOnlySpan<byte>)
Converts the ReadOnlySpan<byte> into a readable string for debugging purposes. Each byte is represented as a decimal value, separated by commas.
public static string ToDebugString(this ReadOnlySpan<byte> span)
Parameters
spanReadOnlySpan<byte>The ReadOnlySpan<byte> to process.
Returns
- string
A string representing the span as comma-separated decimal numbers.
ToDecimal(ReadOnlySpan<byte>, int)
Converts the ReadOnlySpan<byte> into a Decimal number. Size = 16 bytes.
public static decimal ToDecimal(this ReadOnlySpan<byte> span, int position = 0)
Parameters
spanReadOnlySpan<byte>The ReadOnlySpan<byte>.
positionintThe position within the span.
Returns
- decimal
Converted value.
ToDecimal(ReadOnlySpan<byte>, ref int)
Converts the ReadOnlySpan<byte> into a Decimal number. Size = 16 bytes.
public static decimal ToDecimal(this ReadOnlySpan<byte> span, ref int position)
Parameters
spanReadOnlySpan<byte>The ReadOnlySpan<byte>.
positionintThe position within the span. By reference; is auto-incremented by the size of the output type.
Returns
- decimal
Converted value.
ToDecimalOrDefault(ReadOnlySpan<byte>, int, decimal)
Converts the ReadOnlySpan<byte> into a Decimal number. Size = 16 bytes.
public static decimal ToDecimalOrDefault(this ReadOnlySpan<byte> span, int position = 0, decimal defaultValue = 0.0)
Parameters
spanReadOnlySpan<byte>The ReadOnlySpan<byte>.
positionintThe position within the span.
defaultValuedecimalDefault value for that type, can be overridden.
Returns
- decimal
Converted value.
ToDecimalOrDefault(ReadOnlySpan<byte>, ref int, decimal)
Converts the ReadOnlySpan<byte> into a Decimal number. Size = 16 bytes.
public static decimal ToDecimalOrDefault(this ReadOnlySpan<byte> span, ref int position, decimal defaultValue = 0.0)
Parameters
spanReadOnlySpan<byte>The ReadOnlySpan<byte>.
positionintThe position within the span. By reference; is auto-incremented by the size of the output type.
defaultValuedecimalValue returned if out of bounds.
Returns
- decimal
Converted value.
ToDouble(ReadOnlySpan<byte>, int)
Converts the ReadOnlySpan<byte> into a Double-precision floating point number (double). Size = 8 bytes.
public static double ToDouble(this ReadOnlySpan<byte> span, int position = 0)
Parameters
spanReadOnlySpan<byte>The ReadOnlySpan<byte>.
positionintThe position within the span.
Returns
- double
Converted value.
ToDouble(ReadOnlySpan<byte>, ref int)
Converts the ReadOnlySpan<byte> into a Double-precision floating point number (double). Size = 8 bytes.
public static double ToDouble(this ReadOnlySpan<byte> span, ref int position)
Parameters
spanReadOnlySpan<byte>The ReadOnlySpan<byte>.
positionintThe position within the span. By reference; is auto-incremented by the size of the output type.
Returns
- double
Converted value.
ToDoubleOrDefault(ReadOnlySpan<byte>, int, double)
Converts the ReadOnlySpan<byte> into a Double-precision floating point number (double). Size = 8 bytes.
public static double ToDoubleOrDefault(this ReadOnlySpan<byte> span, int position = 0, double defaultValue = 0)
Parameters
spanReadOnlySpan<byte>The ReadOnlySpan<byte>.
positionintThe position within the span.
defaultValuedoubleDefault value for that type, can be overridden.
Returns
- double
Converted value.
ToDoubleOrDefault(ReadOnlySpan<byte>, ref int, double)
Converts the ReadOnlySpan<byte> into a Double-precision floating point number (double). Size = 8 bytes.
public static double ToDoubleOrDefault(this ReadOnlySpan<byte> span, ref int position, double defaultValue = 0)
Parameters
spanReadOnlySpan<byte>The ReadOnlySpan<byte>.
positionintThe position within the span. By reference; is auto-incremented by the size of the output type.
defaultValuedoubleValue returned if out of bounds.
Returns
- double
Converted value.
ToEnumOrDefault<T>(ReadOnlySpan<byte>, int, T)
Converts the ReadOnlySpan<byte> into an Enum value of type T. Returns the default value if conversion fails or value is not defined in the enum. The underlying value is stored as an Int32. Size = 4 bytes.
public static T ToEnumOrDefault<T>(this ReadOnlySpan<byte> span, int position = 0, T defaultValue = default) where T : struct, Enum
Parameters
spanReadOnlySpan<byte>The ReadOnlySpan<byte>.
positionintThe position within the span.
defaultValueTDefault value for that type, can be overridden.
Returns
- T
Converted value.
Type Parameters
TThe enum type.
ToEnumOrDefault<T>(ReadOnlySpan<byte>, ref int, T)
Converts the ReadOnlySpan<byte> into an Enum value of type T. Returns the default value if conversion fails or value is not defined in the enum. The underlying value is stored as an Int32. Size = 4 bytes.
public static T ToEnumOrDefault<T>(this ReadOnlySpan<byte> span, ref int position, T defaultValue = default) where T : struct, Enum
Parameters
spanReadOnlySpan<byte>The ReadOnlySpan<byte>.
positionintThe position within the span. By reference; is auto-incremented by the size of the output type.
defaultValueTValue returned if out of bounds or undefined.
Returns
- T
Converted value.
Type Parameters
TThe enum type.
ToEnum<T>(ReadOnlySpan<byte>, int)
Converts the ReadOnlySpan<byte> into an Enum value of type T. The underlying value is stored as an Int32. Size = 4 bytes.
public static T ToEnum<T>(this ReadOnlySpan<byte> span, int position = 0) where T : struct, Enum
Parameters
spanReadOnlySpan<byte>The ReadOnlySpan<byte>.
positionintThe position within the span.
Returns
- T
Converted value.
Type Parameters
TThe enum type.
ToEnum<T>(ReadOnlySpan<byte>, ref int)
Converts the ReadOnlySpan<byte> into an Enum value of type T. The underlying value is stored as an Int32. Size = 4 bytes.
public static T ToEnum<T>(this ReadOnlySpan<byte> span, ref int position) where T : struct, Enum
Parameters
spanReadOnlySpan<byte>The ReadOnlySpan<byte>.
positionintThe position within the span. By reference; is auto-incremented by the size of the output type.
Returns
- T
Converted value.
Type Parameters
TThe enum type.
Exceptions
- ArgumentException
Thrown if the value is not defined in the enum.
ToGuid(ReadOnlySpan<byte>, int)
Converts the ReadOnlySpan<byte> into a Guid value. Size = 16 bytes.
public static Guid ToGuid(this ReadOnlySpan<byte> span, int position = 0)
Parameters
spanReadOnlySpan<byte>The ReadOnlySpan<byte>.
positionintThe position within the span.
Returns
- Guid
Converted value.
ToGuid(ReadOnlySpan<byte>, ref int)
Converts the ReadOnlySpan<byte> into a Guid value. Size = 16 bytes.
public static Guid ToGuid(this ReadOnlySpan<byte> span, ref int position)
Parameters
spanReadOnlySpan<byte>The ReadOnlySpan<byte>.
positionintThe position within the span. By reference; is auto-incremented by the size of the output type.
Returns
- Guid
Converted value.
ToGuidOrDefault(ReadOnlySpan<byte>, int, Guid)
Converts the ReadOnlySpan<byte> into a Guid value. Size = 16 bytes.
public static Guid ToGuidOrDefault(this ReadOnlySpan<byte> span, int position = 0, Guid defaultValue = default)
Parameters
spanReadOnlySpan<byte>The ReadOnlySpan<byte>.
positionintThe position within the span.
defaultValueGuidDefault value for that type, can be overridden.
Returns
- Guid
Converted value.
ToGuidOrDefault(ReadOnlySpan<byte>, ref int, Guid)
Converts the ReadOnlySpan<byte> into a Guid value. Size = 16 bytes.
public static Guid ToGuidOrDefault(this ReadOnlySpan<byte> span, ref int position, Guid defaultValue = default)
Parameters
spanReadOnlySpan<byte>The ReadOnlySpan<byte>.
positionintThe position within the span. By reference; is auto-incremented by the size of the output type.
defaultValueGuidValue returned if out of bounds.
Returns
- Guid
Converted value.
ToHalf(ReadOnlySpan<byte>, int)
Converts the ReadOnlySpan<byte> into a Half-precision floating point number (Half). Size = 2 bytes.
public static Half ToHalf(this ReadOnlySpan<byte> span, int position = 0)
Parameters
spanReadOnlySpan<byte>The ReadOnlySpan<byte>.
positionintThe position within the span.
Returns
- Half
Converted value.
ToHalf(ReadOnlySpan<byte>, ref int)
Converts the ReadOnlySpan<byte> into a Half-precision floating point number (Half). Size = 2 bytes.
public static Half ToHalf(this ReadOnlySpan<byte> span, ref int position)
Parameters
spanReadOnlySpan<byte>The ReadOnlySpan<byte>.
positionintThe position within the span. By reference; is auto-incremented by the size of the output type.
Returns
- Half
Converted value.
ToHalfOrDefault(ReadOnlySpan<byte>, int, Half)
Converts the ReadOnlySpan<byte> into a Half-precision floating point number (Half). Size = 2 bytes.
public static Half ToHalfOrDefault(this ReadOnlySpan<byte> span, int position = 0, Half defaultValue = default)
Parameters
spanReadOnlySpan<byte>The ReadOnlySpan<byte>.
positionintThe position within the span.
defaultValueHalfDefault value for that type, can be overridden.
Returns
- Half
Converted value.
ToHalfOrDefault(ReadOnlySpan<byte>, ref int, Half)
Converts the ReadOnlySpan<byte> into a Half-precision floating point number (Half). Size = 2 bytes.
public static Half ToHalfOrDefault(this ReadOnlySpan<byte> span, ref int position, Half defaultValue = default)
Parameters
spanReadOnlySpan<byte>The ReadOnlySpan<byte>.
positionintThe position within the span. By reference; is auto-incremented by the size of the output type.
defaultValueHalfValue returned if out of bounds.
Returns
- Half
Converted value.
ToHexDebugString(ReadOnlySpan<byte>)
Converts the given ReadOnlySpan<byte> to its hexadecimal string representation for debugging. Each byte is represented as a two-digit hex value, separated by commas.
public static string ToHexDebugString(this ReadOnlySpan<byte> span)
Parameters
spanReadOnlySpan<byte>The ReadOnlySpan<byte> to process.
Returns
- string
A string representing the span as comma-separated hex numbers.
ToHexString(ReadOnlySpan<byte>)
Converts the entire ReadOnlySpan<byte> into a hexadecimal string representation. Each byte is represented as a two-character hexadecimal value.
public static string ToHexString(this ReadOnlySpan<byte> span)
Parameters
spanReadOnlySpan<byte>The ReadOnlySpan<byte> to convert.
Returns
- string
A hexadecimal string representation.
ToIPv4Address(ReadOnlySpan<byte>, int)
Converts the ReadOnlySpan<byte> into an IPv4 address. Size = 4 bytes.
public static IPAddress ToIPv4Address(this ReadOnlySpan<byte> span, int position = 0)
Parameters
spanReadOnlySpan<byte>The ReadOnlySpan<byte>.
positionintThe position within the span.
Returns
- IPAddress
Converted value.
ToIPv4Address(ReadOnlySpan<byte>, ref int)
Converts the ReadOnlySpan<byte> into an IPv4 address. Size = 4 bytes.
public static IPAddress ToIPv4Address(this ReadOnlySpan<byte> span, ref int position)
Parameters
spanReadOnlySpan<byte>The ReadOnlySpan<byte>.
positionintThe position within the span. By reference; is auto-incremented by the size of the output type.
Returns
- IPAddress
Converted value.
ToIPv4AddressOrDefault(ReadOnlySpan<byte>, int, IPAddress?)
Converts the ReadOnlySpan<byte> into an IPv4 address. Size = 4 bytes.
public static IPAddress ToIPv4AddressOrDefault(this ReadOnlySpan<byte> span, int position = 0, IPAddress? defaultValue = null)
Parameters
spanReadOnlySpan<byte>The ReadOnlySpan<byte>.
positionintThe position within the span.
defaultValueIPAddressDefault value for that type, can be overridden.
Returns
- IPAddress
Converted value.
ToIPv4AddressOrDefault(ReadOnlySpan<byte>, ref int, IPAddress?)
Converts the ReadOnlySpan<byte> into an IPv4 address. Size = 4 bytes.
public static IPAddress ToIPv4AddressOrDefault(this ReadOnlySpan<byte> span, ref int position, IPAddress? defaultValue = null)
Parameters
spanReadOnlySpan<byte>The ReadOnlySpan<byte>.
positionintThe position within the span. By reference; is auto-incremented by the size of the output type.
defaultValueIPAddressValue returned if out of bounds.
Returns
- IPAddress
Converted value.
ToIPv4EndPoint(ReadOnlySpan<byte>, int)
Converts the ReadOnlySpan<byte> into an IPv4 endpoint. Size = 6 bytes (4 bytes IP + 2 bytes port).
public static IPEndPoint ToIPv4EndPoint(this ReadOnlySpan<byte> span, int position = 0)
Parameters
spanReadOnlySpan<byte>The ReadOnlySpan<byte>.
positionintThe position within the span.
Returns
- IPEndPoint
Converted value.
ToIPv4EndPoint(ReadOnlySpan<byte>, ref int)
Converts the ReadOnlySpan<byte> into an IPv4 endpoint. Size = 6 bytes (4 bytes IP + 2 bytes port).
public static IPEndPoint ToIPv4EndPoint(this ReadOnlySpan<byte> span, ref int position)
Parameters
spanReadOnlySpan<byte>The ReadOnlySpan<byte>.
positionintThe position within the span. By reference; is auto-incremented by the size of the output type.
Returns
- IPEndPoint
Converted value.
ToIPv4EndPointOrDefault(ReadOnlySpan<byte>, int, IPEndPoint?)
Converts the ReadOnlySpan<byte> into an IPv4 endpoint. Size = 6 bytes (4 bytes IP + 2 bytes port).
public static IPEndPoint ToIPv4EndPointOrDefault(this ReadOnlySpan<byte> span, int position = 0, IPEndPoint? defaultValue = null)
Parameters
spanReadOnlySpan<byte>The ReadOnlySpan<byte>.
positionintThe position within the span.
defaultValueIPEndPointDefault value for that type, can be overridden.
Returns
- IPEndPoint
Converted value.
ToIPv4EndPointOrDefault(ReadOnlySpan<byte>, ref int, IPEndPoint?)
Converts the ReadOnlySpan<byte> into an IPv4 endpoint. Size = 6 bytes (4 bytes IP + 2 bytes port).
public static IPEndPoint ToIPv4EndPointOrDefault(this ReadOnlySpan<byte> span, ref int position, IPEndPoint? defaultValue = null)
Parameters
spanReadOnlySpan<byte>The ReadOnlySpan<byte>.
positionintThe position within the span. By reference; is auto-incremented by the size of the output type.
defaultValueIPEndPointValue returned if out of bounds.
Returns
- IPEndPoint
Converted value.
ToIPv6Address(ReadOnlySpan<byte>, int)
Converts the ReadOnlySpan<byte> into an IPv6 address. Size = 16 bytes.
public static IPAddress ToIPv6Address(this ReadOnlySpan<byte> span, int position = 0)
Parameters
spanReadOnlySpan<byte>The ReadOnlySpan<byte>.
positionintThe position within the span.
Returns
- IPAddress
Converted value.
ToIPv6Address(ReadOnlySpan<byte>, ref int)
Converts the ReadOnlySpan<byte> into an IPv6 address. Size = 16 bytes.
public static IPAddress ToIPv6Address(this ReadOnlySpan<byte> span, ref int position)
Parameters
spanReadOnlySpan<byte>The ReadOnlySpan<byte>.
positionintThe position within the span. By reference; is auto-incremented by the size of the output type.
Returns
- IPAddress
Converted value.
ToIPv6AddressOrDefault(ReadOnlySpan<byte>, int, IPAddress?)
Converts the ReadOnlySpan<byte> into an IPv6 address. Size = 16 bytes.
public static IPAddress ToIPv6AddressOrDefault(this ReadOnlySpan<byte> span, int position = 0, IPAddress? defaultValue = null)
Parameters
spanReadOnlySpan<byte>The ReadOnlySpan<byte>.
positionintThe position within the span.
defaultValueIPAddressDefault value for that type, can be overridden.
Returns
- IPAddress
Converted value.
ToIPv6AddressOrDefault(ReadOnlySpan<byte>, ref int, IPAddress?)
Converts the ReadOnlySpan<byte> into an IPv6 address. Size = 16 bytes.
public static IPAddress ToIPv6AddressOrDefault(this ReadOnlySpan<byte> span, ref int position, IPAddress? defaultValue = null)
Parameters
spanReadOnlySpan<byte>The ReadOnlySpan<byte>.
positionintThe position within the span. By reference; is auto-incremented by the size of the output type.
defaultValueIPAddressValue returned if out of bounds.
Returns
- IPAddress
Converted value.
ToIPv6EndPoint(ReadOnlySpan<byte>, int)
Converts the ReadOnlySpan<byte> into an IPv6 endpoint. Size = 18 bytes (16 bytes IP + 2 bytes port).
public static IPEndPoint ToIPv6EndPoint(this ReadOnlySpan<byte> span, int position = 0)
Parameters
spanReadOnlySpan<byte>The ReadOnlySpan<byte>.
positionintThe position within the span.
Returns
- IPEndPoint
Converted value.
ToIPv6EndPoint(ReadOnlySpan<byte>, ref int)
Converts the ReadOnlySpan<byte> into an IPv6 endpoint. Size = 18 bytes (16 bytes IP + 2 bytes port).
public static IPEndPoint ToIPv6EndPoint(this ReadOnlySpan<byte> span, ref int position)
Parameters
spanReadOnlySpan<byte>The ReadOnlySpan<byte>.
positionintThe position within the span. By reference; is auto-incremented by the size of the output type.
Returns
- IPEndPoint
Converted value.
ToIPv6EndPointOrDefault(ReadOnlySpan<byte>, int, IPEndPoint?)
Converts the ReadOnlySpan<byte> into an IPv6 endpoint. Size = 18 bytes (16 bytes IP + 2 bytes port).
public static IPEndPoint ToIPv6EndPointOrDefault(this ReadOnlySpan<byte> span, int position = 0, IPEndPoint? defaultValue = null)
Parameters
spanReadOnlySpan<byte>The ReadOnlySpan<byte>.
positionintThe position within the span.
defaultValueIPEndPointDefault value for that type, can be overridden.
Returns
- IPEndPoint
Converted value.
ToIPv6EndPointOrDefault(ReadOnlySpan<byte>, ref int, IPEndPoint?)
Converts the ReadOnlySpan<byte> into an IPv6 endpoint. Size = 18 bytes (16 bytes IP + 2 bytes port).
public static IPEndPoint ToIPv6EndPointOrDefault(this ReadOnlySpan<byte> span, ref int position, IPEndPoint? defaultValue = null)
Parameters
spanReadOnlySpan<byte>The ReadOnlySpan<byte>.
positionintThe position within the span. By reference; is auto-incremented by the size of the output type.
defaultValueIPEndPointValue returned if out of bounds.
Returns
- IPEndPoint
Converted value.
ToInt16(ReadOnlySpan<byte>, int)
Converts the ReadOnlySpan<byte> into a Signed 16-bit integer From -32,768 to 32,767. Size = 2 bytes.
public static short ToInt16(this ReadOnlySpan<byte> span, int position = 0)
Parameters
spanReadOnlySpan<byte>The ReadOnlySpan<byte>.
positionintThe position within the span.
Returns
- short
Converted value.
ToInt16(ReadOnlySpan<byte>, ref int)
Converts the ReadOnlySpan<byte> into a Signed 16-bit integer From -32,768 to 32,767. Size = 2 bytes.
public static short ToInt16(this ReadOnlySpan<byte> span, ref int position)
Parameters
spanReadOnlySpan<byte>The ReadOnlySpan<byte>.
positionintThe position within the span. By reference; is auto-incremented by the size of the output type.
Returns
- short
Converted value.
ToInt16NetworkOrder(ReadOnlySpan<byte>, int)
Converts a signed 16-bit value from network byte order (big-endian) to host byte order (little-endian on most systems).
public static short ToInt16NetworkOrder(this ReadOnlySpan<byte> span, int position = 0)
Parameters
spanReadOnlySpan<byte>The ReadOnlySpan<byte>.
positionintThe position within the span.
Returns
- short
Converted value in host byte order.
ToInt16NetworkOrder(ReadOnlySpan<byte>, ref int)
Converts a signed 16-bit value from network byte order (big-endian) to host byte order (little-endian on most systems).
public static short ToInt16NetworkOrder(this ReadOnlySpan<byte> span, ref int position)
Parameters
spanReadOnlySpan<byte>The ReadOnlySpan<byte>.
positionintThe position within the span. By reference; is auto-incremented by the size of the output type.
Returns
- short
Converted value in host byte order.
ToInt16OrDefault(ReadOnlySpan<byte>, int, short)
Converts the ReadOnlySpan<byte> into a Signed 16-bit integer From -32,768 to 32,767. Size = 2 bytes.
public static short ToInt16OrDefault(this ReadOnlySpan<byte> span, int position = 0, short defaultValue = 0)
Parameters
spanReadOnlySpan<byte>The ReadOnlySpan<byte>.
positionintThe position within the span.
defaultValueshortDefault value for that type, can be overridden.
Returns
- short
Converted value.
ToInt16OrDefault(ReadOnlySpan<byte>, ref int, short)
Converts the ReadOnlySpan<byte> into a Signed 16-bit integer From -32,768 to 32,767. Size = 2 bytes.
public static short ToInt16OrDefault(this ReadOnlySpan<byte> span, ref int position, short defaultValue = 0)
Parameters
spanReadOnlySpan<byte>The ReadOnlySpan<byte>.
positionintThe position within the span. By reference; is auto-incremented by the size of the output type.
defaultValueshortValue returned if out of bounds.
Returns
- short
Converted value.
ToInt32(ReadOnlySpan<byte>, int)
Converts the ReadOnlySpan<byte> into a Signed 32-bit integer From -2,147,483,648 to 2,147,483,647. Size = 4 bytes.
public static int ToInt32(this ReadOnlySpan<byte> span, int position = 0)
Parameters
spanReadOnlySpan<byte>The ReadOnlySpan<byte>.
positionintThe position within the span.
Returns
- int
Converted value.
ToInt32(ReadOnlySpan<byte>, ref int)
Converts the ReadOnlySpan<byte> into a Signed 32-bit integer From -2,147,483,648 to 2,147,483,647. Size = 4 bytes.
public static int ToInt32(this ReadOnlySpan<byte> span, ref int position)
Parameters
spanReadOnlySpan<byte>The ReadOnlySpan<byte>.
positionintThe position within the span. By reference; is auto-incremented by the size of the output type.
Returns
- int
Converted value.
ToInt32NetworkOrder(ReadOnlySpan<byte>, int)
Converts a signed 32-bit value from network byte order (big-endian) to host byte order (little-endian on most systems).
public static int ToInt32NetworkOrder(this ReadOnlySpan<byte> span, int position = 0)
Parameters
spanReadOnlySpan<byte>The ReadOnlySpan<byte>.
positionintThe position within the span.
Returns
- int
Converted value in host byte order.
ToInt32NetworkOrder(ReadOnlySpan<byte>, ref int)
Converts a signed 32-bit value from network byte order (big-endian) to host byte order (little-endian on most systems).
public static int ToInt32NetworkOrder(this ReadOnlySpan<byte> span, ref int position)
Parameters
spanReadOnlySpan<byte>The ReadOnlySpan<byte>.
positionintThe position within the span. By reference; is auto-incremented by the size of the output type.
Returns
- int
Converted value in host byte order.
ToInt32OrDefault(ReadOnlySpan<byte>, int, int)
Converts the ReadOnlySpan<byte> into a Signed 32-bit integer From -2,147,483,648 to 2,147,483,647. Size = 4 bytes.
public static int ToInt32OrDefault(this ReadOnlySpan<byte> span, int position = 0, int defaultValue = 0)
Parameters
spanReadOnlySpan<byte>The ReadOnlySpan<byte>.
positionintThe position within the span.
defaultValueintDefault value for that type, can be overridden.
Returns
- int
Converted value.
ToInt32OrDefault(ReadOnlySpan<byte>, ref int, int)
Converts the ReadOnlySpan<byte> into a Signed 32-bit integer From -2,147,483,648 to 2,147,483,647. Size = 4 bytes.
public static int ToInt32OrDefault(this ReadOnlySpan<byte> span, ref int position, int defaultValue = 0)
Parameters
spanReadOnlySpan<byte>The ReadOnlySpan<byte>.
positionintThe position within the span. By reference; is auto-incremented by the size of the output type.
defaultValueintValue returned if out of bounds.
Returns
- int
Converted value.
ToInt64(ReadOnlySpan<byte>, int)
Converts the ReadOnlySpan<byte> into a Signed 64-bit integer From -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807. Size = 8 bytes.
public static long ToInt64(this ReadOnlySpan<byte> span, int position = 0)
Parameters
spanReadOnlySpan<byte>The ReadOnlySpan<byte>.
positionintThe position within the span.
Returns
- long
Converted value.
ToInt64(ReadOnlySpan<byte>, ref int)
Converts the ReadOnlySpan<byte> into a Signed 64-bit integer From -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807. Size = 8 bytes.
public static long ToInt64(this ReadOnlySpan<byte> span, ref int position)
Parameters
spanReadOnlySpan<byte>The ReadOnlySpan<byte>.
positionintThe position within the span. By reference; is auto-incremented by the size of the output type.
Returns
- long
Converted value.
ToInt64NetworkOrder(ReadOnlySpan<byte>, int)
Converts a signed 64-bit value from network byte order (big-endian) to host byte order (little-endian on most systems).
public static long ToInt64NetworkOrder(this ReadOnlySpan<byte> span, int position = 0)
Parameters
spanReadOnlySpan<byte>The ReadOnlySpan<byte>.
positionintThe position within the span.
Returns
- long
Converted value in host byte order.
ToInt64NetworkOrder(ReadOnlySpan<byte>, ref int)
Converts a signed 64-bit value from network byte order (big-endian) to host byte order (little-endian on most systems).
public static long ToInt64NetworkOrder(this ReadOnlySpan<byte> span, ref int position)
Parameters
spanReadOnlySpan<byte>The ReadOnlySpan<byte>.
positionintThe position within the span. By reference; is auto-incremented by the size of the output type.
Returns
- long
Converted value in host byte order.
ToInt64OrDefault(ReadOnlySpan<byte>, int, long)
Converts the ReadOnlySpan<byte> into a Signed 64-bit integer From -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807. Size = 8 bytes.
public static long ToInt64OrDefault(this ReadOnlySpan<byte> span, int position = 0, long defaultValue = 0)
Parameters
spanReadOnlySpan<byte>The ReadOnlySpan<byte>.
positionintThe position within the span.
defaultValuelongDefault value for that type, can be overridden.
Returns
- long
Converted value.
ToInt64OrDefault(ReadOnlySpan<byte>, ref int, long)
Converts the ReadOnlySpan<byte> into a Signed 64-bit integer From -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807. Size = 8 bytes.
public static long ToInt64OrDefault(this ReadOnlySpan<byte> span, ref int position, long defaultValue = 0)
Parameters
spanReadOnlySpan<byte>The ReadOnlySpan<byte>.
positionintThe position within the span. By reference; is auto-incremented by the size of the output type.
defaultValuelongValue returned if out of bounds.
Returns
- long
Converted value.
ToSByte(ReadOnlySpan<byte>, int)
Extracts a signed byte from the ReadOnlySpan<byte>. Range: -128 to 127. Size = 1 byte.
public static sbyte ToSByte(this ReadOnlySpan<byte> span, int position = 0)
Parameters
spanReadOnlySpan<byte>The ReadOnlySpan<byte>.
positionintThe position within the span.
Returns
- sbyte
The sbyte value.
ToSByte(ReadOnlySpan<byte>, ref int)
Extracts a signed byte from the ReadOnlySpan<byte>. Range: -128 to 127. Size = 1 byte.
public static sbyte ToSByte(this ReadOnlySpan<byte> span, ref int position)
Parameters
spanReadOnlySpan<byte>The ReadOnlySpan<byte>.
positionintThe position within the span. By reference; is auto-incremented by the size of the output type.
Returns
- sbyte
The sbyte value.
ToSByteOrDefault(ReadOnlySpan<byte>, int, sbyte)
Extracts a signed byte from the ReadOnlySpan<byte>. Range: -128 to 127. Size = 1 byte.
public static sbyte ToSByteOrDefault(this ReadOnlySpan<byte> span, int position = 0, sbyte defaultValue = 0)
Parameters
spanReadOnlySpan<byte>The ReadOnlySpan<byte>.
positionintThe position within the span.
defaultValuesbyteDefault value for that type, can be overridden.
Returns
- sbyte
The sbyte value.
ToSByteOrDefault(ReadOnlySpan<byte>, ref int, sbyte)
Extracts a signed byte from the ReadOnlySpan<byte>. Range: -128 to 127. Size = 1 byte.
public static sbyte ToSByteOrDefault(this ReadOnlySpan<byte> span, ref int position, sbyte defaultValue = 0)
Parameters
spanReadOnlySpan<byte>The ReadOnlySpan<byte>.
positionintThe position within the span. By reference; is auto-incremented by the size of the output type.
defaultValuesbyteValue returned if out of bounds.
Returns
- sbyte
The sbyte value.
ToSingle(ReadOnlySpan<byte>, int)
Converts the ReadOnlySpan<byte> into a Single-precision floating point number (float). Size = 4 bytes.
public static float ToSingle(this ReadOnlySpan<byte> span, int position = 0)
Parameters
spanReadOnlySpan<byte>The ReadOnlySpan<byte>.
positionintThe position within the span.
Returns
- float
Converted value.
ToSingle(ReadOnlySpan<byte>, ref int)
Converts the ReadOnlySpan<byte> into a Single-precision floating point number (float). Size = 4 bytes.
public static float ToSingle(this ReadOnlySpan<byte> span, ref int position)
Parameters
spanReadOnlySpan<byte>The ReadOnlySpan<byte>.
positionintThe position within the span. By reference; is auto-incremented by the size of the output type.
Returns
- float
Converted value.
ToSingleOrDefault(ReadOnlySpan<byte>, int, float)
Converts the ReadOnlySpan<byte> into a Single-precision floating point number (float). Size = 4 bytes.
public static float ToSingleOrDefault(this ReadOnlySpan<byte> span, int position = 0, float defaultValue = 0)
Parameters
spanReadOnlySpan<byte>The ReadOnlySpan<byte>.
positionintThe position within the span.
defaultValuefloatDefault value for that type, can be overridden.
Returns
- float
Converted value.
ToSingleOrDefault(ReadOnlySpan<byte>, ref int, float)
Converts the ReadOnlySpan<byte> into a Single-precision floating point number (float). Size = 4 bytes.
public static float ToSingleOrDefault(this ReadOnlySpan<byte> span, ref int position, float defaultValue = 0)
Parameters
spanReadOnlySpan<byte>The ReadOnlySpan<byte>.
positionintThe position within the span. By reference; is auto-incremented by the size of the output type.
defaultValuefloatValue returned if out of bounds.
Returns
- float
Converted value.
ToTimeSpan(ReadOnlySpan<byte>, int)
Converts the ReadOnlySpan<byte> into a TimeSpan value. The TimeSpan is stored as a 64-bit integer representing ticks. Size = 8 bytes.
public static TimeSpan ToTimeSpan(this ReadOnlySpan<byte> span, int position = 0)
Parameters
spanReadOnlySpan<byte>The ReadOnlySpan<byte>.
positionintThe position within the span.
Returns
- TimeSpan
Converted value.
ToTimeSpan(ReadOnlySpan<byte>, ref int)
Converts the ReadOnlySpan<byte> into a TimeSpan value. The TimeSpan is stored as a 64-bit integer representing ticks. Size = 8 bytes.
public static TimeSpan ToTimeSpan(this ReadOnlySpan<byte> span, ref int position)
Parameters
spanReadOnlySpan<byte>The ReadOnlySpan<byte>.
positionintThe position within the span. By reference; is auto-incremented by the size of the output type.
Returns
- TimeSpan
Converted value.
ToTimeSpanOrDefault(ReadOnlySpan<byte>, int, TimeSpan)
Converts the ReadOnlySpan<byte> into a TimeSpan value. The TimeSpan is stored as a 64-bit integer representing ticks. Size = 8 bytes.
public static TimeSpan ToTimeSpanOrDefault(this ReadOnlySpan<byte> span, int position = 0, TimeSpan defaultValue = default)
Parameters
spanReadOnlySpan<byte>The ReadOnlySpan<byte>.
positionintThe position within the span.
defaultValueTimeSpanDefault value for that type, can be overridden.
Returns
- TimeSpan
Converted value.
ToTimeSpanOrDefault(ReadOnlySpan<byte>, ref int, TimeSpan)
Converts the ReadOnlySpan<byte> into a TimeSpan value. The TimeSpan is stored as a 64-bit integer representing ticks. Size = 8 bytes.
public static TimeSpan ToTimeSpanOrDefault(this ReadOnlySpan<byte> span, ref int position, TimeSpan defaultValue = default)
Parameters
spanReadOnlySpan<byte>The ReadOnlySpan<byte>.
positionintThe position within the span. By reference; is auto-incremented by the size of the output type.
defaultValueTimeSpanValue returned if out of bounds.
Returns
- TimeSpan
Converted value.
ToUInt16(ReadOnlySpan<byte>, int)
Converts the ReadOnlySpan<byte> into an Unsigned 16-bit integer From 0 to 65,535. Size = 2 bytes.
public static ushort ToUInt16(this ReadOnlySpan<byte> span, int position = 0)
Parameters
spanReadOnlySpan<byte>The ReadOnlySpan<byte>.
positionintThe position within the span.
Returns
- ushort
Converted value.
ToUInt16(ReadOnlySpan<byte>, ref int)
Converts the ReadOnlySpan<byte> into an Unsigned 16-bit integer From 0 to 65,535. Size = 2 bytes.
public static ushort ToUInt16(this ReadOnlySpan<byte> span, ref int position)
Parameters
spanReadOnlySpan<byte>The ReadOnlySpan<byte>.
positionintThe position within the span. By reference; is auto-incremented by the size of the output type.
Returns
- ushort
Converted value.
ToUInt16NetworkOrder(ReadOnlySpan<byte>, int)
Converts a 16-bit value from network byte order (big-endian) to host byte order (little-endian on most systems).
public static ushort ToUInt16NetworkOrder(this ReadOnlySpan<byte> span, int position = 0)
Parameters
spanReadOnlySpan<byte>The ReadOnlySpan<byte>.
positionintThe position within the span.
Returns
- ushort
Converted value in host byte order.
ToUInt16NetworkOrder(ReadOnlySpan<byte>, ref int)
Converts a 16-bit value from network byte order (big-endian) to host byte order (little-endian on most systems).
public static ushort ToUInt16NetworkOrder(this ReadOnlySpan<byte> span, ref int position)
Parameters
spanReadOnlySpan<byte>The ReadOnlySpan<byte>.
positionintThe position within the span. By reference; is auto-incremented by the size of the output type.
Returns
- ushort
Converted value in host byte order.
ToUInt16OrDefault(ReadOnlySpan<byte>, int, ushort)
Converts the ReadOnlySpan<byte> into an Unsigned 16-bit integer From 0 to 65,535. Size = 2 bytes.
public static ushort ToUInt16OrDefault(this ReadOnlySpan<byte> span, int position = 0, ushort defaultValue = 0)
Parameters
spanReadOnlySpan<byte>The ReadOnlySpan<byte>.
positionintThe position within the span.
defaultValueushortDefault value for that type, can be overridden.
Returns
- ushort
Converted value.
ToUInt16OrDefault(ReadOnlySpan<byte>, ref int, ushort)
Converts the ReadOnlySpan<byte> into an Unsigned 16-bit integer From 0 to 65,535. Size = 2 bytes.
public static ushort ToUInt16OrDefault(this ReadOnlySpan<byte> span, ref int position, ushort defaultValue = 0)
Parameters
spanReadOnlySpan<byte>The ReadOnlySpan<byte>.
positionintThe position within the span. By reference; is auto-incremented by the size of the output type.
defaultValueushortDefault value for that type, can be overridden.
Returns
- ushort
Converted value.
ToUInt32(ReadOnlySpan<byte>, int)
Converts the ReadOnlySpan<byte> into an Unsigned 32-bit integer From 0 to 4,294,967,295. Size = 4 bytes.
public static uint ToUInt32(this ReadOnlySpan<byte> span, int position = 0)
Parameters
spanReadOnlySpan<byte>The ReadOnlySpan<byte>.
positionintThe position within the span.
Returns
- uint
Converted value.
ToUInt32(ReadOnlySpan<byte>, ref int)
Converts the ReadOnlySpan<byte> into an Unsigned 32-bit integer From 0 to 4,294,967,295. Size = 4 bytes.
public static uint ToUInt32(this ReadOnlySpan<byte> span, ref int position)
Parameters
spanReadOnlySpan<byte>The ReadOnlySpan<byte>.
positionintThe position within the span. By reference; is auto-incremented by the size of the output type.
Returns
- uint
Converted value.
ToUInt32NetworkOrder(ReadOnlySpan<byte>, int)
Converts a 32-bit value from network byte order (big-endian) to host byte order (little-endian on most systems).
public static uint ToUInt32NetworkOrder(this ReadOnlySpan<byte> span, int position = 0)
Parameters
spanReadOnlySpan<byte>The ReadOnlySpan<byte>.
positionintThe position within the span.
Returns
- uint
Converted value in host byte order.
ToUInt32NetworkOrder(ReadOnlySpan<byte>, ref int)
Converts a 32-bit value from network byte order (big-endian) to host byte order (little-endian on most systems).
public static uint ToUInt32NetworkOrder(this ReadOnlySpan<byte> span, ref int position)
Parameters
spanReadOnlySpan<byte>The ReadOnlySpan<byte>.
positionintThe position within the span. By reference; is auto-incremented by the size of the output type.
Returns
- uint
Converted value in host byte order.
ToUInt32OrDefault(ReadOnlySpan<byte>, int, uint)
Converts the ReadOnlySpan<byte> into an Unsigned 32-bit integer From 0 to 4,294,967,295. Size = 4 bytes.
public static uint ToUInt32OrDefault(this ReadOnlySpan<byte> span, int position = 0, uint defaultValue = 0)
Parameters
spanReadOnlySpan<byte>The ReadOnlySpan<byte>.
positionintThe position within the span.
defaultValueuintDefault value for that type, can be overridden.
Returns
- uint
Converted value.
ToUInt32OrDefault(ReadOnlySpan<byte>, ref int, uint)
Converts the ReadOnlySpan<byte> into an Unsigned 32-bit integer From 0 to 4,294,967,295. Size = 4 bytes.
public static uint ToUInt32OrDefault(this ReadOnlySpan<byte> span, ref int position, uint defaultValue = 0)
Parameters
spanReadOnlySpan<byte>The ReadOnlySpan<byte>.
positionintThe position within the span. By reference; is auto-incremented by the size of the output type.
defaultValueuintDefault value for that type, can be overridden.
Returns
- uint
Converted value.
ToUInt64(ReadOnlySpan<byte>, int)
Converts the ReadOnlySpan<byte> into an Unsigned 64-bit integer From 0 to 18,446,744,073,709,551,615. Size = 8 bytes.
public static ulong ToUInt64(this ReadOnlySpan<byte> span, int position = 0)
Parameters
spanReadOnlySpan<byte>The ReadOnlySpan<byte>.
positionintThe position within the span.
Returns
- ulong
Converted value.
ToUInt64(ReadOnlySpan<byte>, ref int)
Converts the ReadOnlySpan<byte> into an Unsigned 64-bit integer From 0 to 18,446,744,073,709,551,615. Size = 8 bytes.
public static ulong ToUInt64(this ReadOnlySpan<byte> span, ref int position)
Parameters
spanReadOnlySpan<byte>The ReadOnlySpan<byte>.
positionintThe position within the span. By reference; is auto-incremented by the size of the output type.
Returns
- ulong
Converted value.
ToUInt64NetworkOrder(ReadOnlySpan<byte>, int)
Converts a 64-bit value from network byte order (big-endian) to host byte order (little-endian on most systems).
public static ulong ToUInt64NetworkOrder(this ReadOnlySpan<byte> span, int position = 0)
Parameters
spanReadOnlySpan<byte>The ReadOnlySpan<byte>.
positionintThe position within the span.
Returns
- ulong
Converted value in host byte order.
ToUInt64NetworkOrder(ReadOnlySpan<byte>, ref int)
Converts a 64-bit value from network byte order (big-endian) to host byte order (little-endian on most systems).
public static ulong ToUInt64NetworkOrder(this ReadOnlySpan<byte> span, ref int position)
Parameters
spanReadOnlySpan<byte>The ReadOnlySpan<byte>.
positionintThe position within the span. By reference; is auto-incremented by the size of the output type.
Returns
- ulong
Converted value in host byte order.
ToUInt64OrDefault(ReadOnlySpan<byte>, int, ulong)
Converts the ReadOnlySpan<byte> into an Unsigned 64-bit integer From 0 to 18,446,744,073,709,551,615. Size = 8 bytes.
public static ulong ToUInt64OrDefault(this ReadOnlySpan<byte> span, int position = 0, ulong defaultValue = 0)
Parameters
spanReadOnlySpan<byte>The ReadOnlySpan<byte>.
positionintThe position within the span.
defaultValueulongDefault value for that type, can be overridden.
Returns
- ulong
Converted value.
ToUInt64OrDefault(ReadOnlySpan<byte>, ref int, ulong)
Converts the ReadOnlySpan<byte> into an Unsigned 64-bit integer From 0 to 18,446,744,073,709,551,615. Size = 8 bytes.
public static ulong ToUInt64OrDefault(this ReadOnlySpan<byte> span, ref int position, ulong defaultValue = 0)
Parameters
spanReadOnlySpan<byte>The ReadOnlySpan<byte>.
positionintThe position within the span. By reference; is auto-incremented by the size of the output type.
defaultValueulongDefault value for that type, can be overridden.
Returns
- ulong
Converted value.
ToUtf16String(ReadOnlySpan<byte>, int, int)
Converts parts of a ReadOnlySpan<byte> into a UTF-16 String.
public static string ToUtf16String(this ReadOnlySpan<byte> span, int position = 0, int numberOfBytesToRead = -1)
Parameters
spanReadOnlySpan<byte>The ReadOnlySpan<byte>.
positionintThe position within the span.
numberOfBytesToReadintNumber of bytes to read. If -1, reads from position to end of span.
Returns
- string
Converted value.
ToUtf16String(ReadOnlySpan<byte>, ref int, int)
Converts parts of a ReadOnlySpan<byte> into a UTF-16 String.
public static string ToUtf16String(this ReadOnlySpan<byte> span, ref int position, int numberOfBytesToRead = -1)
Parameters
spanReadOnlySpan<byte>The ReadOnlySpan<byte>.
positionintThe position within the span. By reference; is auto-incremented by the size of the output type.
numberOfBytesToReadintNumber of bytes to read. If -1, reads from position to end of span.
Returns
- string
Converted value.
ToUtf16StringOrDefault(ReadOnlySpan<byte>, int, int, string)
Converts parts of a ReadOnlySpan<byte> into a UTF-16 String.
public static string ToUtf16StringOrDefault(this ReadOnlySpan<byte> span, int position = 0, int numberOfBytesToRead = -1, string defaultValue = "")
Parameters
spanReadOnlySpan<byte>The ReadOnlySpan<byte>.
positionintThe position within the span.
numberOfBytesToReadintNumber of bytes to read. If -1, reads from position to end of span.
defaultValuestringDefault value for that type, can be overridden.
Returns
- string
Converted value.
ToUtf16StringOrDefault(ReadOnlySpan<byte>, ref int, int, string)
Converts parts of a ReadOnlySpan<byte> into a UTF-16 String.
public static string ToUtf16StringOrDefault(this ReadOnlySpan<byte> span, ref int position, int numberOfBytesToRead = -1, string defaultValue = "")
Parameters
spanReadOnlySpan<byte>The ReadOnlySpan<byte>.
positionintThe position within the span. By reference; is auto-incremented by the size of the output type.
numberOfBytesToReadintNumber of bytes to read. If -1, reads from position to end of span.
defaultValuestringDefault value for that type, can be overridden.
Returns
- string
Converted value.
ToUtf8String(ReadOnlySpan<byte>, int, int)
Converts parts of a ReadOnlySpan<byte> into a UTF-8 String.
public static string ToUtf8String(this ReadOnlySpan<byte> span, int position = 0, int numberOfBytesToRead = -1)
Parameters
spanReadOnlySpan<byte>The ReadOnlySpan<byte>.
positionintThe position within the span.
numberOfBytesToReadintNumber of bytes to read. If -1, reads from position to end of span.
Returns
- string
Converted value.
ToUtf8String(ReadOnlySpan<byte>, ref int, int)
Converts parts of a ReadOnlySpan<byte> into a UTF-8 String.
public static string ToUtf8String(this ReadOnlySpan<byte> span, ref int position, int numberOfBytesToRead = -1)
Parameters
spanReadOnlySpan<byte>The ReadOnlySpan<byte>.
positionintThe position within the span. By reference; is auto-incremented by the size of the output type.
numberOfBytesToReadintNumber of bytes to read. If -1, reads from position to end of span.
Returns
- string
Converted value.
ToUtf8StringOrDefault(ReadOnlySpan<byte>, int, int, string)
Converts parts of a ReadOnlySpan<byte> into a UTF-8 String.
public static string ToUtf8StringOrDefault(this ReadOnlySpan<byte> span, int position = 0, int numberOfBytesToRead = -1, string defaultValue = "")
Parameters
spanReadOnlySpan<byte>The ReadOnlySpan<byte>.
positionintThe position within the span.
numberOfBytesToReadintNumber of bytes to read. If -1, reads from position to end of span.
defaultValuestringDefault value for that type, can be overridden.
Returns
- string
Converted value.
ToUtf8StringOrDefault(ReadOnlySpan<byte>, ref int, int, string)
Converts parts of a ReadOnlySpan<byte> into a UTF-8 String.
public static string ToUtf8StringOrDefault(this ReadOnlySpan<byte> span, ref int position, int numberOfBytesToRead = -1, string defaultValue = "")
Parameters
spanReadOnlySpan<byte>The ReadOnlySpan<byte>.
positionintThe position within the span. By reference; is auto-incremented by the size of the output type.
numberOfBytesToReadintNumber of bytes to read. If -1, reads from position to end of span.
defaultValuestringDefault value for that type, can be overridden.
Returns
- string
Converted value.
ToVersion(ReadOnlySpan<byte>, int)
Converts the ReadOnlySpan<byte> into a Version object. The Version is stored as: major (int32), minor (int32), build (int32), revision (int32). Size = 16 bytes.
public static Version ToVersion(this ReadOnlySpan<byte> span, int position = 0)
Parameters
spanReadOnlySpan<byte>The ReadOnlySpan<byte>.
positionintThe position within the span.
Returns
- Version
Converted value.
ToVersion(ReadOnlySpan<byte>, ref int)
Converts the ReadOnlySpan<byte> into a Version object. The Version is stored as: major (int32), minor (int32), build (int32), revision (int32). Size = 16 bytes.
public static Version ToVersion(this ReadOnlySpan<byte> span, ref int position)
Parameters
spanReadOnlySpan<byte>The ReadOnlySpan<byte>.
positionintThe position within the span. By reference; is auto-incremented by the size of the output type.
Returns
- Version
Converted value.
ToVersionOrDefault(ReadOnlySpan<byte>, int, Version?)
Converts the ReadOnlySpan<byte> into a Version object. Returns the default value if conversion fails. The Version is stored as: major (int32), minor (int32), build (int32), revision (int32). Size = 16 bytes.
public static Version ToVersionOrDefault(this ReadOnlySpan<byte> span, int position = 0, Version? defaultValue = null)
Parameters
spanReadOnlySpan<byte>The ReadOnlySpan<byte>.
positionintThe position within the span.
defaultValueVersionDefault value for that type, can be overridden.
Returns
- Version
Converted value.
ToVersionOrDefault(ReadOnlySpan<byte>, ref int, Version?)
Converts the ReadOnlySpan<byte> into a Version object. Returns the default value if conversion fails. The Version is stored as: major (int32), minor (int32), build (int32), revision (int32). Size = 16 bytes.
public static Version ToVersionOrDefault(this ReadOnlySpan<byte> span, ref int position, Version? defaultValue = null)
Parameters
spanReadOnlySpan<byte>The ReadOnlySpan<byte>.
positionintThe position within the span. By reference; is auto-incremented by the size of the output type.
defaultValueVersionValue returned if out of bounds.
Returns
- Version
Converted value.