MemoryExtensions Class

Definition

Provides extension methods for for the memory- and span-related types, such as Memory<T>, ReadOnlyMemory<T>, Span<T>, and ReadOnlySpan<T>.

public ref class MemoryExtensions abstract sealed
public static class MemoryExtensions
type MemoryExtensions = class
Public Module MemoryExtensions
Inheritance
MemoryExtensions

Methods

AsMemory(String)

Creates a new ReadOnlyMemory<Char> over the portion of the target string.

AsMemory(String, Index)

Creates a new ReadOnlyMemory<Char> over a portion of the target string starting at a specified index.

AsMemory(String, Int32)

Creates a new ReadOnlyMemory<Char> over a portion of the target string starting at a specified character position.

AsMemory(String, Int32, Int32)

Creates a new ReadOnlyMemory<Char> over a portion of the target string beginning at a specified position with a length.

AsMemory(String, Range)

Creates a new ReadOnlyMemory<Char> over a specified range of the target string.

AsMemory<T>(ArraySegment<T>)

Creates a new memory region over the portion of the target array segment.

AsMemory<T>(ArraySegment<T>, Int32)

Creates a new memory region over the portion of the target array segment starting at a specified position to the end of the segment.

AsMemory<T>(ArraySegment<T>, Int32, Int32)

Creates a new memory region over the portion of the target array segment beginning at a specified position with a specified length.

AsMemory<T>(T[])

Creates a new memory region over the target array.

AsMemory<T>(T[], Index)

Creates a new memory region over the portion of the target array starting at a specified index to the end of the array.

AsMemory<T>(T[], Int32)

Creates a new memory region over the portion of the target array starting at a specified position to the end of the array.

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

Creates a new memory region over the portion of the target array beginning at a specified position with a specified length.

AsMemory<T>(T[], Range)

Creates a new memory region over the portion of the target array beginning at inclusive start index of the range and ending at the exclusive end index of the range.

AsSpan(String)

Creates a new read-only span over a portion of the target string from a specified position for a specified number of characters.

AsSpan(String, Int32)

Creates a new read-only span over a portion of the target string from a specified position to the end of the string.

AsSpan(String, Int32, Int32)

Creates a new read-only span over a string.

AsSpan<T>(ArraySegment<T>)

Creates a new span over a target array segment.

AsSpan<T>(ArraySegment<T>, Index)

Creates a new span over a portion of the target array segment beginning at a specified index and ending at the end of the segment.

AsSpan<T>(ArraySegment<T>, Int32)

Creates a new span over a portion of a target array segment from a specified position to the end of the segment.

AsSpan<T>(ArraySegment<T>, Int32, Int32)

Creates a new span over a portion of a target array segment from a specified position for a specified length.

AsSpan<T>(ArraySegment<T>, Range)

Creates a new span over a portion of a target array segment using the range start and end indexes.

AsSpan<T>(T[])

Creates a new span over a target array.

AsSpan<T>(T[], Index)

Creates a new span over the portion of the target array defined by an Index value.

AsSpan<T>(T[], Int32)

Creates a new span over a portion of the target array starting at a specified position to the end of the array.

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

Creates a new span over the portion of the target array beginning at a specified position for a specified length.

AsSpan<T>(T[], Range)

Creates a new span over a portion of a target array defined by a Range value.

BinarySearch<T,TComparable>(ReadOnlySpan<T>, TComparable)

Searches an entire sorted ReadOnlySpan<T> for a value using the specified TComparable generic type.

BinarySearch<T,TComparable>(Span<T>, TComparable)

Searches an entire sorted Span<T> for a value using the specified TComparable generic type.

BinarySearch<T,TComparer>(ReadOnlySpan<T>, T, TComparer)

Searches an entire sorted ReadOnlySpan<T> for a specified value using the specified TComparer generic type.

BinarySearch<T,TComparer>(Span<T>, T, TComparer)

Searches an entire sorted Span<T> for a specified value using the specified TComparer generic type.

BinarySearch<T>(ReadOnlySpan<T>, IComparable<T>)

Searches an entire sorted ReadOnlySpan<T> for a value using the specified IComparable<T> generic interface.

BinarySearch<T>(Span<T>, IComparable<T>)

Searches an entire sorted Span<T> for a value using the specified IComparable<T> generic interface.

CompareTo(ReadOnlySpan<Char>, ReadOnlySpan<Char>, StringComparison)

Compares one character span with another using a specified string comparison, and returns an integer that indicates their relative position in the sort order.

Contains(ReadOnlySpan<Char>, ReadOnlySpan<Char>, StringComparison)

Indicates whether a specified value occurs within a read-only character span.

Contains<T>(ReadOnlySpan<T>, T)

Indicates whether a specified value is found in a read-only span. Values are compared using IEquatable{T}.Equals(T).

Contains<T>(Span<T>, T)

Indicates whether a specified value is found in a span. Values are compared using IEquatable{T}.Equals(T).

CopyTo<T>(T[], Memory<T>)

Copies the contents of the array into a memory region.

CopyTo<T>(T[], Span<T>)

Copies the contents of the array into the span.

EndsWith(ReadOnlySpan<Char>, ReadOnlySpan<Char>, StringComparison)

Determines whether the end of the span matches the specified value when compared using the specified comparisonType option.

EndsWith<T>(ReadOnlySpan<T>, ReadOnlySpan<T>)

Determines whether the specified sequence appears at the end of a read-only span.

EndsWith<T>(Span<T>, ReadOnlySpan<T>)

Determines whether the specified sequence appears at the end of a span.

EnumerateRunes(ReadOnlySpan<Char>)

Returns an enumeration of Rune from the provided read-only span.

EnumerateRunes(Span<Char>)

Returns an enumeration of Rune from the provided span.

Equals(ReadOnlySpan<Char>, ReadOnlySpan<Char>, StringComparison)

Determines whether this span and the specified other span have the same characters when compared using the specified comparisonType option.

IndexOf(ReadOnlySpan<Char>, ReadOnlySpan<Char>, StringComparison)

Reports the zero-based index of the first occurrence of the specified value in the current span.

IndexOf<T>(ReadOnlySpan<T>, ReadOnlySpan<T>)

Searches for the specified sequence and returns the index of its first occurrence. Values are compared using IEquatable{T}.Equals(T).

IndexOf<T>(ReadOnlySpan<T>, T)

Searches for the specified value and returns the index of its first occurrence. Values are compared using IEquatable{T}.Equals(T).

IndexOf<T>(Span<T>, ReadOnlySpan<T>)

Searches for the specified sequence and returns the index of its first occurrence. Values are compared using IEquatable{T}.Equals(T).

IndexOf<T>(Span<T>, T)

Searches for the specified value and returns the index of its first occurrence. Values are compared using IEquatable{T}.Equals(T).

IndexOfAny<T>(ReadOnlySpan<T>, ReadOnlySpan<T>)

Searches for the first index of any of the specified values similar to calling IndexOf several times with the logical OR operator.

IndexOfAny<T>(ReadOnlySpan<T>, T, T)

Searches for the first index of any of the specified values similar to calling IndexOf several times with the logical OR operator.

IndexOfAny<T>(ReadOnlySpan<T>, T, T, T)

Searches for the first index of any of the specified values similar to calling IndexOf several times with the logical OR operator.

IndexOfAny<T>(Span<T>, ReadOnlySpan<T>)

Searches for the first index of any of the specified values similar to calling IndexOf several times with the logical OR operator.

IndexOfAny<T>(Span<T>, T, T)

Searches for the first index of any of the specified values similar to calling IndexOf several times with the logical OR operator.

IndexOfAny<T>(Span<T>, T, T, T)

Searches for the first index of any of the specified values similar to calling IndexOf several times with the logical OR operator.

IsWhiteSpace(ReadOnlySpan<Char>)

Indicates whether the specified span contains only whitespace characters.

LastIndexOf(ReadOnlySpan<Char>, ReadOnlySpan<Char>, StringComparison)

Reports the zero-based index of the last occurrence of the specified value in the current span.

LastIndexOf<T>(ReadOnlySpan<T>, ReadOnlySpan<T>)

Searches for the specified sequence and returns the index of its last occurrence. Values are compared using IEquatable{T}.Equals(T).

LastIndexOf<T>(ReadOnlySpan<T>, T)

Searches for the specified value and returns the index of its last occurrence. Values are compared using IEquatable{T}.Equals(T).

LastIndexOf<T>(Span<T>, ReadOnlySpan<T>)

Searches for the specified sequence and returns the index of its last occurrence. Values are compared using IEquatable{T}.Equals(T).

LastIndexOf<T>(Span<T>, T)

Searches for the specified value and returns the index of its last occurrence. Values are compared using IEquatable{T}.Equals(T).

LastIndexOfAny<T>(ReadOnlySpan<T>, ReadOnlySpan<T>)

Searches for the last index of any of the specified values similar to calling LastIndexOf several times with the logical OR operator.

LastIndexOfAny<T>(ReadOnlySpan<T>, T, T)

Searches for the last index of any of the specified values similar to calling LastIndexOf several times with the logical OR operator.

LastIndexOfAny<T>(ReadOnlySpan<T>, T, T, T)

Searches for the last index of any of the specified values similar to calling LastIndexOf several times with the logical OR operator.

LastIndexOfAny<T>(Span<T>, ReadOnlySpan<T>)

Searches for the last index of any of the specified values similar to calling LastIndexOf several times with the logical OR operator.

LastIndexOfAny<T>(Span<T>, T, T)

Searches for the last index of any of the specified values similar to calling LastIndexOf several times with the logical OR operator.

LastIndexOfAny<T>(Span<T>, T, T, T)

Searches for the last index of any of the specified values similar to calling LastIndexOf several times with the logical OR operator.

Overlaps<T>(ReadOnlySpan<T>, ReadOnlySpan<T>)

Determines whether two read-only sequences overlap in memory.

Overlaps<T>(ReadOnlySpan<T>, ReadOnlySpan<T>, Int32)

Determines whether two read-only sequences overlap in memory and outputs the element offset.

Overlaps<T>(Span<T>, ReadOnlySpan<T>)

Determines whether a span and a read-only span overlap in memory.

Overlaps<T>(Span<T>, ReadOnlySpan<T>, Int32)

Determines whether a span and a read-only span overlap in memory and outputs the element offset.

Reverse<T>(Span<T>)

Reverses the sequence of the elements in the entire span.

SequenceCompareTo<T>(ReadOnlySpan<T>, ReadOnlySpan<T>)

Determines the relative order of two read-only sequences by comparing their elements using IComparable{T}.CompareTo(T).

SequenceCompareTo<T>(Span<T>, ReadOnlySpan<T>)

Determines the relative order of a span and a read-only span by comparing the elements using IComparable{T}.CompareTo(T).

SequenceEqual<T>(ReadOnlySpan<T>, ReadOnlySpan<T>)

Determines whether two read-only sequences are equal by comparing the elements using IEquatable{T}.Equals(T).

SequenceEqual<T>(Span<T>, ReadOnlySpan<T>)

Determines whether a span and a read-only span are equal by comparing the elements using IEquatable{T}.Equals(T).

StartsWith(ReadOnlySpan<Char>, ReadOnlySpan<Char>, StringComparison)

Determines whether a read-only character span begins with a specified value when compared using a specified StringComparison value.

StartsWith<T>(ReadOnlySpan<T>, ReadOnlySpan<T>)

Determines whether a specified sequence appears at the start of a read-only span.

StartsWith<T>(Span<T>, ReadOnlySpan<T>)

Determines whether a specified sequence appears at the start of a span.

ToLower(ReadOnlySpan<Char>, Span<Char>, CultureInfo)

Copies the characters from the source span into the destination, converting each character to lowercase, using the casing rules of the specified culture.

ToLowerInvariant(ReadOnlySpan<Char>, Span<Char>)

Copies the characters from the source span into the destination, converting each character to lowercase, using the casing rules of the invariant culture.

ToUpper(ReadOnlySpan<Char>, Span<Char>, CultureInfo)

Copies the characters from the source span into the destination, converting each character to uppercase, using the casing rules of the specified culture.

ToUpperInvariant(ReadOnlySpan<Char>, Span<Char>)

Copies the characters from the source span into the destination, converting each character to uppercase using the casing rules of the invariant culture.

Trim(Memory<Char>)

Removes all leading and trailing whitespace characters from a character memory region.

Trim(ReadOnlyMemory<Char>)

Removes all leading and trailing whitespace characters from a read-only character memory region.

Trim(ReadOnlySpan<Char>)

Removes all leading and trailing whitespace characters from a read-only character span.

Trim(ReadOnlySpan<Char>, Char)

Removes all leading and trailing occurrences of a specified character from a read-only character span.

Trim(ReadOnlySpan<Char>, ReadOnlySpan<Char>)

Removes all leading and trailing occurrences of a set of characters specified in a read-only span from a read-only character span.

Trim(Span<Char>)

Removes all leading and trailing whitespace characters from a character span.

Trim<T>(Memory<T>, ReadOnlySpan<T>)

Removes all leading and trailing occurrences of a set of elements specified in a read-only span from a memory region.

Trim<T>(Memory<T>, T)

Removes all leading and trailing occurrences of a specified element from a memory region.

Trim<T>(ReadOnlyMemory<T>, ReadOnlySpan<T>)

Removes all leading and trailing occurrences of a set of elements specified in a read-only span from a read-only memory region.

Trim<T>(ReadOnlyMemory<T>, T)

Removes all leading and trailing occurrences of a specified element from a read-only memory region.

Trim<T>(ReadOnlySpan<T>, ReadOnlySpan<T>)

Removes all leading and trailing occurrences of a set of elements specified in a read-only span from a read-only span.

Trim<T>(ReadOnlySpan<T>, T)

Removes all leading and trailing occurrences of a specified element from a read-only span.

Trim<T>(Span<T>, ReadOnlySpan<T>)

Removes all leading and trailing occurrences of a set of elements specified in a read-only span from a span.

Trim<T>(Span<T>, T)

Removes all leading and trailing occurrences of a specified element from a span.

TrimEnd(Memory<Char>)

Removes all trailing whitespace characters from a character memory region.

TrimEnd(ReadOnlyMemory<Char>)

Removes all trailing whitespace characters from a read-only character memory region.

TrimEnd(ReadOnlySpan<Char>)

Removes all trailing whitespace characters from a read-only character span.

TrimEnd(ReadOnlySpan<Char>, Char)

Removes all trailing occurrences of a specified character from a read-only span.

TrimEnd(ReadOnlySpan<Char>, ReadOnlySpan<Char>)

Removes all trailing occurrences of a set of characters specified in a read-only span from a read-only character span.

TrimEnd(Span<Char>)

Removes all trailing whitespace characters from a character span.

TrimEnd<T>(Memory<T>, ReadOnlySpan<T>)

Removes all trailing occurrences of a set of elements specified in a read-only span from a memory region.

TrimEnd<T>(Memory<T>, T)

Removes all trailing occurrences of a specified element from a character memory region.

TrimEnd<T>(ReadOnlyMemory<T>, ReadOnlySpan<T>)

Removes all trailing occurrences of a set of elements specified in a read-only span from a read-only memory region.

TrimEnd<T>(ReadOnlyMemory<T>, T)

Removes all trailing occurrences of a specified element from a read-only memory region.

TrimEnd<T>(ReadOnlySpan<T>, ReadOnlySpan<T>)

Removes all trailing occurrences of a set of elements specified in a read-only span from a read-only span.

TrimEnd<T>(ReadOnlySpan<T>, T)

Removes all trailing occurrences of a specified element from a read-only span.

TrimEnd<T>(Span<T>, ReadOnlySpan<T>)

Removes all trailing occurrences of a set of elements specified in a read-only span from a span.

TrimEnd<T>(Span<T>, T)

Removes all trailing occurrences of a specified element from a span.

TrimStart(Memory<Char>)

Removes all leading whitespace characters from a memory region.

TrimStart(ReadOnlyMemory<Char>)

Removes all leading whitespace characters from a read-only memory region.

TrimStart(ReadOnlySpan<Char>)

Removes all leading whitespace characters from a read-only span.

TrimStart(ReadOnlySpan<Char>, Char)

Removes all leading occurrences of a specified character from the span.

TrimStart(ReadOnlySpan<Char>, ReadOnlySpan<Char>)

Removes all leading occurrences of a set of characters specified in a read-only span from the span.

TrimStart(Span<Char>)

Removes all leading whitespace characters from a span.

TrimStart<T>(Memory<T>, ReadOnlySpan<T>)

Removes all leading occurrences of a set of elements specified in a read-only span from a memory region.

TrimStart<T>(Memory<T>, T)

Removes all leading occurrences of a specified element from a memory region.

TrimStart<T>(ReadOnlyMemory<T>, ReadOnlySpan<T>)

Removes all leading occurrences of a set of elements specified in a read-only span from a memory region.

TrimStart<T>(ReadOnlyMemory<T>, T)

Removes all leading occurrences of a specified element from a memory region.

TrimStart<T>(ReadOnlySpan<T>, ReadOnlySpan<T>)

Removes all leading occurrences of a set of elements specified in a read-only span from the span.

TrimStart<T>(ReadOnlySpan<T>, T)

Removes all leading occurrences of a specified element from the span.

TrimStart<T>(Span<T>, ReadOnlySpan<T>)

Removes all leading occurrences of a set of elements specified in a read-only span from the span.

TrimStart<T>(Span<T>, T)

Removes all leading occurrences of a specified element from the span.

Applies to