Прочетете на английски Редактиране

Споделяне чрез


ReadOnlySequence<T> Constructors

Definition

Overloads

ReadOnlySequence<T>(ReadOnlyMemory<T>)

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

ReadOnlySequence<T>(T[])

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

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

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

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>(ReadOnlyMemory<T>)

Source:
ReadOnlySequence.cs
Source:
ReadOnlySequence.cs
Source:
ReadOnlySequence.cs

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

C#
public ReadOnlySequence(ReadOnlyMemory<T> memory);

Parameters

memory
ReadOnlyMemory<T>

A read-only block of memory of elements of type T.

Remarks

The consumer is expected to manage the lifetime of memory until ReadOnlySequence<T> is not used anymore.

Applies to

.NET 10 и други версии
Продукт Версии
.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

ReadOnlySequence<T>(T[])

Source:
ReadOnlySequence.cs
Source:
ReadOnlySequence.cs
Source:
ReadOnlySequence.cs

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

C#
public ReadOnlySequence(T[] array);

Parameters

array
T[]

The array from which to create a read-only sequence.

Applies to

.NET 10 и други версии
Продукт Версии
.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

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

Source:
ReadOnlySequence.cs
Source:
ReadOnlySequence.cs
Source:
ReadOnlySequence.cs

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

C#
public ReadOnlySequence(T[] array, int start, int length);

Parameters

array
T[]

The array from which to create the read-only sequence.

start
Int32

The zero-based index of the first element in the array to include in the read-only sequence.

length
Int32

The number of elements to include in the read-only sequence.

Applies to

.NET 10 и други версии
Продукт Версии
.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

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

Source:
ReadOnlySequence.cs
Source:
ReadOnlySequence.cs
Source:
ReadOnlySequence.cs

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

C#
public ReadOnlySequence(System.Buffers.ReadOnlySequenceSegment<T> startSegment, int startIndex, System.Buffers.ReadOnlySequenceSegment<T> endSegment, int endIndex);

Parameters

startSegment
ReadOnlySequenceSegment<T>

The initial node of the linked memory list.

startIndex
Int32

The position to the start of the sequence inside startSegment.

endSegment
ReadOnlySequenceSegment<T>

The final node of the linked memory list.

endIndex
Int32

The position to the end of the sequence inside endSegment.

Exceptions

startSegment or endSegment is null.

The running index of startSegment is greater than the running index of endSegment, even though startSegment is different to endSegment.

-or-

startSegment is equal to endSegment but endIndex is smaller than startIndex.

-or-

startIndex is greater than the length of the underlying memory block of startSegment.

Applies to

.NET 10 и други версии
Продукт Версии
.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