Edit

Share via


ReadOnlySequence<T> Struct

Definition

Important

Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.

Represents a sequence that can read a sequential series of T.

C#
public readonly struct ReadOnlySequence<T>

Type Parameters

T

The type of the elements in the read-only sequence.

Inheritance
ReadOnlySequence<T>

Constructors

ReadOnlySequence<T>(ReadOnlyMemory<T>)

Creates an instance of ReadOnlySequence<T> from a ReadOnlyMemory<T>.

ReadOnlySequence<T>(ReadOnlySequenceSegment<T>, Int32, ReadOnlySequenceSegment<T>, Int32)

Creates an instance of a ReadOnlySequence<T> from a linked memory list represented by start and end segments and the corresponding indexes in them.

ReadOnlySequence<T>(T[], Int32, Int32)

Creates an instance of a ReadOnlySequence<T> from a section of an array.

ReadOnlySequence<T>(T[])

Creates an instance of ReadOnlySequence<T> from the array.

Fields

Empty

Returns an empty ReadOnlySequence<T>.

Properties

End

Gets the position at the end of the ReadOnlySequence<T>.

First

Gets the ReadOnlyMemory<T> from the first segment.

FirstSpan

Gets the ReadOnlySpan<T> from the first segment.

IsEmpty

Gets a value that indicates whether the ReadOnlySequence<T> is empty.

IsSingleSegment

Gets a value that indicates whether the ReadOnlySequence<T> contains a single ReadOnlyMemory<T> segment.

Length

Gets the length of the ReadOnlySequence<T>.

Start

Gets the position to the start of the ReadOnlySequence<T>.

Methods

GetEnumerator()

Returns an enumerator over the ReadOnlySequence<T>.

GetOffset(SequencePosition)

Returns the offset of a position within this sequence from the start.

GetPosition(Int64, SequencePosition)

Returns a new SequencePosition starting at the specified offset from the origin position.

GetPosition(Int64)

Returns a new SequencePosition at an offset from the start of the sequence.

Slice(Int32, Int32)

Forms a slice out of the current ReadOnlySequence<T>, beginning at start, with length items.

Slice(Int32, SequencePosition)

Forms a slice out of the current ReadOnlySequence<T>, beginning at start and ending at end (exclusive).

Slice(Int64, Int64)

Forms a slice out of the given ReadOnlySequence<T>, beginning at start, with length items.

Slice(Int64, SequencePosition)

Forms a slice out of the current ReadOnlySequence<T>, beginning at start and ending at end (exclusive).

Slice(Int64)

Forms a slice out of the current ReadOnlySequence<T>, beginning at a specified index and continuing to the end of the read-only sequence.

Slice(SequencePosition, Int32)

Forms a slice out of the current ReadOnlySequence<T>, beginning at start, with length items.

Slice(SequencePosition, Int64)

Forms a slice out of the current ReadOnlySequence<T>, beginning at start, with length items.

Slice(SequencePosition, SequencePosition)

Forms a slice out of the current ReadOnlySequence<T>, beginning at start and ending at end (exclusive).

Slice(SequencePosition)

Forms a slice out of the current ReadOnlySequence<T>, beginning at a specified sequence position and continuing to the end of the read-only sequence.

ToString()

Returns a string that represents the current sequence.

TryGet(SequencePosition, ReadOnlyMemory<T>, Boolean)

Tries to retrieve the next segment after position and returns a value that indicates whether the operation succeeded.

Extension Methods

CopyTo<T>(ReadOnlySequence<T>, Span<T>)

Copies the ReadOnlySequence<T> to the specified Span<T>.

PositionOf<T>(ReadOnlySequence<T>, T)

Returns the position of the first occurrence of value in the ReadOnlySequence<T>.

ToArray<T>(ReadOnlySequence<T>)

Converts the ReadOnlySequence<T> to an array.

Applies to

Product Versions
.NET Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Standard 2.0 (package-provided), 2.1