LaunchDarkly Dotnet Client SDK
Search Results for

    Show / Hide Table of Contents

    Struct Utf8ByteSpan

    Points to a span of UTF-8-encoded text in a buffer.

    Inherited Members
    ValueType.Equals(object)
    ValueType.GetHashCode()
    ValueType.ToString()
    object.GetType()
    object.Equals(object, object)
    object.ReferenceEquals(object, object)
    Namespace: LaunchDarkly.EventSource
    Assembly: LaunchDarkly.EventSource.dll
    Syntax
    public struct Utf8ByteSpan
    Remarks

    This is similar to the Span type in .NET 5. It is used internally by EventSource to store event data if the stream is using UTF-8 encoding. If so, reading DataUtf8Bytes will return the same byte array, to avoid unnecessary copying.

    Constructors

    Utf8ByteSpan(byte[], int, int)

    Constructs a new instance.

    Declaration
    public Utf8ByteSpan(byte[] data, int offset, int length)
    Parameters
    Type Name Description
    byte[] data

    The byte array containing the data.

    int offset

    The offset of the first relevant byte of data within the array.

    int length

    The number of bytes of relevant data within the array.

    Utf8ByteSpan(string)

    Constructs a new instance by copying a string.

    Declaration
    public Utf8ByteSpan(string s)
    Parameters
    Type Name Description
    string s

    A string to convert to UTF-8 bytes.

    Properties

    Data

    The byte array containing the data. May be null if Length is zero.

    Declaration
    public byte[] Data { get; }
    Property Value
    Type Description
    byte[]
    Remarks

    It is the caller's responsibility not to modify the array.

    Length

    The number of bytes of relevant data within the array. This may be less than Data.Length if the span represents a subset of a larger buffer.

    Declaration
    public int Length { get; }
    Property Value
    Type Description
    int

    Offset

    The offset of the first relevant byte of data within the array. This may be greater than zero if the span represents a subset of a larger buffer.

    Declaration
    public int Offset { get; }
    Property Value
    Type Description
    int

    Methods

    Equals(Utf8ByteSpan)

    Tests whether the bytes in this span are the same as another span.

    Declaration
    public bool Equals(Utf8ByteSpan other)
    Parameters
    Type Name Description
    Utf8ByteSpan other

    Another Utf8ByteSpan.

    Returns
    Type Description
    bool

    True if the two spans have the same length and the same data, starting from each one's Offset.

    Equals(string)

    Tests whether the bytes in this span are the same as the UTF-8 encoding of the specified string.

    Declaration
    public bool Equals(string s)
    Parameters
    Type Name Description
    string s

    A string.

    Returns
    Type Description
    bool

    True if the bytes are equivalent.

    Remarks

    This method is potentially inefficient and should be used only in testing.

    GetString()

    Converts the UTF-8 byte data to a string.

    Declaration
    public string GetString()
    Returns
    Type Description
    string

    A new string.

    In this article
    Back to top Generated by DocFX