ReadOnlySpan<T> ReadOnlySpan<T> ReadOnlySpan<T> ReadOnlySpan<T> Struct

Definición

Proporciona una representación de solo lectura con seguridad de tipos y memoria de una región contigua de memoria arbitraria.Provides a type-safe and memory-safe read-only representation of a contiguous region of arbitrary memory.

generic <typename T>
public value class ReadOnlySpan
public struct ReadOnlySpan<T>
type ReadOnlySpan<'T> = struct
Public Structure ReadOnlySpan(Of T)

Parámetros de tipo

T

El tipo de elementos en el ReadOnlySpan<T>.The type of items in the ReadOnlySpan<T>.

Herencia
ReadOnlySpan<T>ReadOnlySpan<T>ReadOnlySpan<T>ReadOnlySpan<T>

Comentarios

ReadOnlySpan<T> es un ref struct que se asigna en la pila y nunca puede escape al montón administrado.ReadOnlySpan<T> is a ref struct that is allocated on the stack and can never escape to the managed heap. Tipos de struct ref tienen un número de restricciones para asegurarse de que no se puede promocionar al montón administrado, incluidos los que no se puede realizar la conversión boxing, capturados en las expresiones lambda, asignadas a variables de tipo Object, asignado a dynamic variables, y no pueden implementar cualquier tipo de interfaz.Ref struct types have a number of restrictions to ensure that they cannot be promoted to the managed heap, including that they can't be boxed, captured in lambda expressions, assigned to variables of type Object, assigned to dynamic variables, and they cannot implement any interface type.

Un ReadOnlySpan<T> instancia a menudo se usa para hacer referencia a los elementos de una matriz o una parte de una matriz.A ReadOnlySpan<T> instance is often used to reference the elements of an array or a portion of an array. A diferencia de una matriz, sin embargo, un ReadOnlySpan<T> instancia puede apuntar a la memoria administrada, memoria nativa, o memoria administrada en la pila.Unlike an array, however, a ReadOnlySpan<T> instance can point to managed memory, native memory, or memory managed on the stack.

Constructores

ReadOnlySpan<T>(T[]) ReadOnlySpan<T>(T[]) ReadOnlySpan<T>(T[]) ReadOnlySpan<T>(T[])

Crea un objeto ReadOnlySpan<T> con la totalidad de una matriz especificada.Creates a new ReadOnlySpan<T> over the entirety of a specified array.

ReadOnlySpan<T>(Void*, Int32) ReadOnlySpan<T>(Void*, Int32) ReadOnlySpan<T>(Void*, Int32) ReadOnlySpan<T>(Void*, Int32)

Crea un objeto ReadOnlySpan<T> a partir de un número especificado de elementos T desde una dirección de memoria especificada.Creates a new ReadOnlySpan<T> from a specified number of T elements starting at a specified memory address.

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

Crea un objeto ReadOnlySpan<T> que incluye un número especificado de elementos de una matriz a partir de un índice especificado.Creates a new ReadOnlySpan<T> that includes a specified number of elements of an array starting at a specified index.

Propiedades

Empty Empty Empty Empty

Devuelve una ReadOnlySpan<T> vacía.Returns an empty ReadOnlySpan<T>.

IsEmpty IsEmpty IsEmpty IsEmpty

Devuelve un valor que indica que el intervalo actual de solo lectura está vacío.Returns a value that indicates the current read-only span is empty.

Item[Int32] Item[Int32] Item[Int32] Item[Int32]

Obtiene un elemento del intervalo de solo lectura en el índice de base cero especificado.Gets an item from the read-only span at the specified zero-based index.

Item[Range] Item[Range] Item[Range] Item[Range]
Item[Index] Item[Index] Item[Index] Item[Index]
Length Length Length Length

El número de elementos del intervalo de solo lectura.The number of items in the read-only span.

Métodos

CopyTo(Span<T>) CopyTo(Span<T>) CopyTo(Span<T>) CopyTo(Span<T>)

Copia el contenido de este elemento ReadOnlySpan<T> en un elemento Span<T> de destino.Copies the contents of this ReadOnlySpan<T> into a destination Span<T>.

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

No se admite.Not supported. Produce una excepción NotSupportedException.Throws a NotSupportedException.

GetEnumerator() GetEnumerator() GetEnumerator() GetEnumerator()

Devuelve un enumerador para este elemento ReadOnlySpan<T>.Returns an enumerator for this ReadOnlySpan<T>.

GetHashCode() GetHashCode() GetHashCode() GetHashCode()

No se admite.Not supported. Produce una excepción NotSupportedException.Throws a NotSupportedException.

Slice(Index) Slice(Index) Slice(Index) Slice(Index)
Slice(Int32) Slice(Int32) Slice(Int32) Slice(Int32)

Forma un segmento fuera del intervalo actual de solo lectura que comienza en un índice especificado.Forms a slice out of the current read-only span that begins at a specified index.

Slice(Range) Slice(Range) Slice(Range) Slice(Range)
Slice(Int32, Int32) Slice(Int32, Int32) Slice(Int32, Int32) Slice(Int32, Int32)

Forma un segmento fuera del intervalo actual de solo lectura a partir de un índice especificado durante una longitud determinada.Forms a slice out of the current read-only span starting at a specified index for a specified length.

ToArray() ToArray() ToArray() ToArray()

Copia el contenido de este intervalo de solo lectura en una nueva matriz.Copies the contents of this read-only span into a new array.

ToString() ToString() ToString() ToString()

Devuelve la representación de cadena de este ReadOnlySpan<T>.Returns the string representation of this ReadOnlySpan<T>.

TryCopyTo(Span<T>) TryCopyTo(Span<T>) TryCopyTo(Span<T>) TryCopyTo(Span<T>)

Intenta copiar el contenido de ReadOnlySpan<T> en Span<T> y devuelve un valor para indicar si la operación se ha realizado correctamente o no.Attempts to copy the contents of this ReadOnlySpan<T> into a Span<T> and returns a value to indicate whether or not the operation succeeded.

Operadores

Equality(ReadOnlySpan<T>, ReadOnlySpan<T>) Equality(ReadOnlySpan<T>, ReadOnlySpan<T>) Equality(ReadOnlySpan<T>, ReadOnlySpan<T>) Equality(ReadOnlySpan<T>, ReadOnlySpan<T>)

Devuelve un valor que indica si dos instancias de ReadOnlySpan<T> son iguales.Returns a value that indicates whether two ReadOnlySpan<T> instances are equal.

Implicit(ArraySegment<T> to ReadOnlySpan<T>) Implicit(ArraySegment<T> to ReadOnlySpan<T>) Implicit(ArraySegment<T> to ReadOnlySpan<T>) Implicit(ArraySegment<T> to ReadOnlySpan<T>)

Define una conversión implícita de un elemento ArraySegment<T> en ReadOnlySpan<T>.Defines an implicit conversion of an ArraySegment<T> to a ReadOnlySpan<T>.

Implicit(T[] to ReadOnlySpan<T>) Implicit(T[] to ReadOnlySpan<T>) Implicit(T[] to ReadOnlySpan<T>) Implicit(T[] to ReadOnlySpan<T>)

Define una conversión implícita de una matriz en ReadOnlySpan<T>.Defines an implicit conversion of an array to a ReadOnlySpan<T>.

Inequality(ReadOnlySpan<T>, ReadOnlySpan<T>) Inequality(ReadOnlySpan<T>, ReadOnlySpan<T>) Inequality(ReadOnlySpan<T>, ReadOnlySpan<T>) Inequality(ReadOnlySpan<T>, ReadOnlySpan<T>)

Devuelve un valor que indica si dos instancias de ReadOnlySpan<T> no son iguales.Returns a value that indicates whether two ReadOnlySpan<T> instances are not equal.

Extension Methods

BinarySearch<T>(ReadOnlySpan<T>, IComparable<T>) BinarySearch<T>(ReadOnlySpan<T>, IComparable<T>) BinarySearch<T>(ReadOnlySpan<T>, IComparable<T>) BinarySearch<T>(ReadOnlySpan<T>, IComparable<T>)
BinarySearch<T,TComparer>(ReadOnlySpan<T>, T, TComparer) BinarySearch<T,TComparer>(ReadOnlySpan<T>, T, TComparer) BinarySearch<T,TComparer>(ReadOnlySpan<T>, T, TComparer) BinarySearch<T,TComparer>(ReadOnlySpan<T>, T, TComparer)
BinarySearch<T,TComparable>(ReadOnlySpan<T>, TComparable) BinarySearch<T,TComparable>(ReadOnlySpan<T>, TComparable) BinarySearch<T,TComparable>(ReadOnlySpan<T>, TComparable) BinarySearch<T,TComparable>(ReadOnlySpan<T>, TComparable)
EndsWith<T>(ReadOnlySpan<T>, ReadOnlySpan<T>) EndsWith<T>(ReadOnlySpan<T>, ReadOnlySpan<T>) EndsWith<T>(ReadOnlySpan<T>, ReadOnlySpan<T>) EndsWith<T>(ReadOnlySpan<T>, ReadOnlySpan<T>)
IndexOf<T>(ReadOnlySpan<T>, T) IndexOf<T>(ReadOnlySpan<T>, T) IndexOf<T>(ReadOnlySpan<T>, T) IndexOf<T>(ReadOnlySpan<T>, T)
IndexOf<T>(ReadOnlySpan<T>, ReadOnlySpan<T>) IndexOf<T>(ReadOnlySpan<T>, ReadOnlySpan<T>) IndexOf<T>(ReadOnlySpan<T>, ReadOnlySpan<T>) IndexOf<T>(ReadOnlySpan<T>, ReadOnlySpan<T>)
IndexOfAny<T>(ReadOnlySpan<T>, T, T) IndexOfAny<T>(ReadOnlySpan<T>, T, T) IndexOfAny<T>(ReadOnlySpan<T>, T, T) IndexOfAny<T>(ReadOnlySpan<T>, T, T)
IndexOfAny<T>(ReadOnlySpan<T>, T, T, T) IndexOfAny<T>(ReadOnlySpan<T>, T, T, T) IndexOfAny<T>(ReadOnlySpan<T>, T, T, T) IndexOfAny<T>(ReadOnlySpan<T>, T, T, T)
IndexOfAny<T>(ReadOnlySpan<T>, ReadOnlySpan<T>) IndexOfAny<T>(ReadOnlySpan<T>, ReadOnlySpan<T>) IndexOfAny<T>(ReadOnlySpan<T>, ReadOnlySpan<T>) IndexOfAny<T>(ReadOnlySpan<T>, ReadOnlySpan<T>)
LastIndexOf<T>(ReadOnlySpan<T>, T) LastIndexOf<T>(ReadOnlySpan<T>, T) LastIndexOf<T>(ReadOnlySpan<T>, T) LastIndexOf<T>(ReadOnlySpan<T>, T)
LastIndexOf<T>(ReadOnlySpan<T>, ReadOnlySpan<T>) LastIndexOf<T>(ReadOnlySpan<T>, ReadOnlySpan<T>) LastIndexOf<T>(ReadOnlySpan<T>, ReadOnlySpan<T>) LastIndexOf<T>(ReadOnlySpan<T>, ReadOnlySpan<T>)
LastIndexOfAny<T>(ReadOnlySpan<T>, T, T) LastIndexOfAny<T>(ReadOnlySpan<T>, T, T) LastIndexOfAny<T>(ReadOnlySpan<T>, T, T) LastIndexOfAny<T>(ReadOnlySpan<T>, T, T)
LastIndexOfAny<T>(ReadOnlySpan<T>, T, T, T) LastIndexOfAny<T>(ReadOnlySpan<T>, T, T, T) LastIndexOfAny<T>(ReadOnlySpan<T>, T, T, T) LastIndexOfAny<T>(ReadOnlySpan<T>, T, T, T)
LastIndexOfAny<T>(ReadOnlySpan<T>, ReadOnlySpan<T>) LastIndexOfAny<T>(ReadOnlySpan<T>, ReadOnlySpan<T>) LastIndexOfAny<T>(ReadOnlySpan<T>, ReadOnlySpan<T>) LastIndexOfAny<T>(ReadOnlySpan<T>, ReadOnlySpan<T>)
Overlaps<T>(ReadOnlySpan<T>, ReadOnlySpan<T>) Overlaps<T>(ReadOnlySpan<T>, ReadOnlySpan<T>) Overlaps<T>(ReadOnlySpan<T>, ReadOnlySpan<T>) Overlaps<T>(ReadOnlySpan<T>, ReadOnlySpan<T>)
Overlaps<T>(ReadOnlySpan<T>, ReadOnlySpan<T>, Int32) Overlaps<T>(ReadOnlySpan<T>, ReadOnlySpan<T>, Int32) Overlaps<T>(ReadOnlySpan<T>, ReadOnlySpan<T>, Int32) Overlaps<T>(ReadOnlySpan<T>, ReadOnlySpan<T>, Int32)
SequenceCompareTo<T>(ReadOnlySpan<T>, ReadOnlySpan<T>) SequenceCompareTo<T>(ReadOnlySpan<T>, ReadOnlySpan<T>) SequenceCompareTo<T>(ReadOnlySpan<T>, ReadOnlySpan<T>) SequenceCompareTo<T>(ReadOnlySpan<T>, ReadOnlySpan<T>)
SequenceEqual<T>(ReadOnlySpan<T>, ReadOnlySpan<T>) SequenceEqual<T>(ReadOnlySpan<T>, ReadOnlySpan<T>) SequenceEqual<T>(ReadOnlySpan<T>, ReadOnlySpan<T>) SequenceEqual<T>(ReadOnlySpan<T>, ReadOnlySpan<T>)
StartsWith<T>(ReadOnlySpan<T>, ReadOnlySpan<T>) StartsWith<T>(ReadOnlySpan<T>, ReadOnlySpan<T>) StartsWith<T>(ReadOnlySpan<T>, ReadOnlySpan<T>) StartsWith<T>(ReadOnlySpan<T>, ReadOnlySpan<T>)

Se aplica a