Early Preview
This is currently very much a preview. Please feel free to try things out,
but don't be upset if anything is not yet working. Feedback is welcome over on our
GitHub Dicussions page.
class System.​MemoryExtensions
Assembly: System.Memory
Inheritance: object → MemoryExtensions
Provides extension methods for the memory-related and span-related types, such as <see cref="T:System.Memory`1" /> , <see cref="T:System.ReadOnlyMemory`1" /> , <see cref="T:System.Span`1" /> , and <see cref="T:System.ReadOnlySpan`1" /> .
Methods
public static
ReadOnlyMemory<​char>
AsMemory​(string text)
Creates a new <see langword="ReadOnlyMemory<Char>" /> over the portion of the target string.
Returns The read-only character memory representation of the string, or <see langword="default" /> if <paramref name="text" /> is <see langword="null" /> .
text
The target string.
public static
ReadOnlyMemory<​char>
AsMemory​(string text,
Index startIndex)
Creates a new <see langword="ReadOnlyMemory<Char>" /> over a portion of the target string starting at a specified index.
Returns The read-only character memory representation of the string.
text
The target string.
startIndex
The index at which to begin this slice.
public static
ReadOnlyMemory<​char>
AsMemory​(string text,
int start)
Creates a new <see langword="ReadOnlyMemory<Char>" /> over a portion of the target string starting at a specified character position.
Returns The read-only character memory representation of the string, or <see langword="default" /> if <paramref name="text" /> is <see langword="null" /> .
text
The target string.
start
The index at which to begin this slice.
public static
ReadOnlyMemory<​char>
AsMemory​(string text,
int start,
int length)
Creates a new <see langword="ReadOnlyMemory<Char>" /> over a portion of the target string beginning at a specified position with a length.
Returns The read-only character memory representation of the string, or <see langword="default" /> if <paramref name="text" /> is <see langword="null" /> .
text
The target string.
start
The index at which to begin this slice.
length
The desired length for the slice.
public static
ReadOnlyMemory<​char>
AsMemory​(string text,
Range range)
Creates a new <see langword="ReadOnlyMemory<Char>" /> over a specified range of the target string.
Returns The read-only character memory representation of the string.
text
The target string.
range
The range that indicates the start and length of the sliced string.
public static
Memory<​T>
AsMemory​(ArraySegment<​T> segment)
Creates a new memory region over the portion of the target array segment.
Returns The memory representation of the segment.
segment
The segment to convert.
public static
Memory<​T>
AsMemory​(ArraySegment<​T> segment,
int start)
Creates a new memory region over the portion of the target array segment starting at a specified position to the end of the segment.
Returns The memory representation of the whole or part of the array.
segment
The target array segment.
start
The index at which to begin the memory.
public static
Memory<​T>
AsMemory​(ArraySegment<​T> segment,
int start,
int length)
Creates a new memory region over the portion of the target array segment beginning at a specified position with a specified length.
Returns The memory representation of the whole or part of the array.
segment
The target array segment.
start
The index at which to begin the memory.
length
The number of items in the memory.
public static
Memory<​T>
AsMemory​(T[] array)
Creates a new memory region over the target array.
Returns The memory representation of the whole or part of the array.
array
The array to convert.
public static
Memory<​T>
AsMemory​(T[] array,
Index startIndex)
Creates a new memory region over the portion of the target array starting at a specified index to the end of the array.
Returns The memory representation of the whole or part of the array.
array
The array to convert.
startIndex
The first position of the array.
public static
Memory<​T>
AsMemory​(T[] array,
int start)
Creates a new memory region over the portion of the target array starting at a specified position to the end of the array.
Returns The memory representation of the whole or part of the array.
array
The target array.
start
The index at which to begin the memory.
public static
Memory<​T>
AsMemory​(T[] array,
int start,
int length)
Creates a new memory region over the portion of the target array beginning at a specified position with a specified length.
Returns The memory representation of the whole or part of the array.
array
The target array.
start
The index at which to begin the memory region.
length
The number of items in the memory region.
public static
Memory<​T>
AsMemory​(T[] array,
Range 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.
Returns The memory representation of the whole or part of the array.
array
The array to convert.
range
The range to convert from the array.
public static
ReadOnlySpan<​char>
AsSpan​(string text)
Creates a new read-only span over a string.
Returns The read-only span representation of the string.
text
The target string.
public static
ReadOnlySpan<​char>
AsSpan​(string text,
int start)
Creates a new read-only span over a portion of the target string from a specified position to the end of the string.
Returns The read-only span representation of the string.
text
The target string.
start
The index at which to begin this slice.
public static
ReadOnlySpan<​char>
AsSpan​(string text,
int start,
int length)
Creates a new read-only span over a portion of the target string from a specified position for a specified number of characters.
Returns The read-only span representation of the string.
text
The target string.
start
The index at which to begin this slice.
length
The desired length for the slice.
public static
ReadOnlySpan<​char>
AsSpan​(string text,
Index startIndex)
Creates a new <see cref="T:System.ReadOnlySpan`1" /> over a portion of the target string from a specified position to the end of the string.
text
The target string.
startIndex
The index at which to begin this slice.
public static
ReadOnlySpan<​char>
AsSpan​(string text,
Range range)
Creates a new <see cref="T:System.ReadOnlySpan`1" /> over a portion of a target string using the range start and end indexes.
text
The target string.
range
The range that has start and end indexes to use for slicing the string.
public static
Span<​T>
AsSpan​(ArraySegment<​T> segment)
Creates a new span over a target array segment.
Returns The span representation of the array segment.
segment
The array segment to convert.
public static
Span<​T>
AsSpan​(ArraySegment<​T> segment,
Index startIndex)
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.
Returns The span representation of the array segment.
segment
The target array segment.
startIndex
The index at which to begin the Span.
public static
Span<​T>
AsSpan​(ArraySegment<​T> segment,
int start)
Creates a new span over a portion of a target array segment from a specified position to the end of the segment.
Returns The span representation of the array segment.
segment
The target array segment.
start
The index at which to begin the san.
public static
Span<​T>
AsSpan​(ArraySegment<​T> segment,
int start,
int length)
Creates a new span over a portion of a target array segment from a specified position for a specified length.
Returns The span representation of the array.
segment
The target array segment.
start
The index at which to begin the span.
length
The number of items in the span.
public static
Span<​T>
AsSpan​(ArraySegment<​T> segment,
Range range)
Creates a new span over a portion of a target array segment using the range start and end indexes.
Returns The span representation of the array segment.
segment
The target array segment.
range
The range which has start and end indexes to use for slicing the array.
public static
Span<​T>
AsSpan​(T[] array)
Creates a new span over a target array.
Returns The span representation of the array.
array
The array to convert.
public static
Span<​T>
AsSpan​(T[] array,
Index startIndex)
Creates a new span over the portion of the target array defined by an <see cref="T:System.Index" /> value.
Returns The span representation of the array.
array
The array to convert.
startIndex
The starting index.
public static
Span<​T>
AsSpan​(T[] array,
int start)
Creates a new span over a portion of the target array starting at a specified position to the end of the array.
Returns The span representation of the array.
array
The array to convert.
start
The initial index from which the array will be converted.
public static
Span<​T>
AsSpan​(T[] array,
int start,
int length)
Creates a new span over the portion of the target array beginning at a specified position for a specified length.
Returns The span representation of the array.
array
The target array.
start
The index at which to begin the span.
length
The number of items in the span.
public static
Span<​T>
AsSpan​(T[] array,
Range range)
Creates a new span over a portion of a target array defined by a <see cref="T:System.Range" /> value.
Returns The span representation of the array.
array
The array to convert.
range
The range of the array to convert.
public static
int
BinarySearch​(ReadOnlySpan<​T> span,
IComparable<​T> comparable)
Searches an entire sorted <see cref="T:System.ReadOnlySpan`1" /> for a value using the specified <see cref="T:System.IComparable`1" /> generic interface.
Returns The zero-based index of <paramref name="comparable" /> in the sorted <paramref name="span" /> , if <paramref name="comparable" /> is found; otherwise, a negative number that is the bitwise complement of the index of the next element that is larger than <paramref name="comparable" /> or, if there is no larger element, the bitwise complement of <see cref="P:System.ReadOnlySpan`1.Length" /> .
span
The sorted <see cref="T:System.ReadOnlySpan`1" /> to search.
comparable
The <see cref="T:System.IComparable`1" /> to use when comparing.
public static
int
BinarySearch​(Span<​T> span,
IComparable<​T> comparable)
Searches an entire sorted <see cref="T:System.Span`1" /> for a value using the specified <see cref="T:System.IComparable`1" /> generic interface.
Returns The zero-based index of <paramref name="comparable" /> in the sorted <paramref name="span" /> , if <paramref name="comparable" /> is found; otherwise, a negative number that is the bitwise complement of the index of the next element that is larger than <paramref name="comparable" /> or, if there is no larger element, the bitwise complement of <see cref="P:System.Span`1.Length" /> .
span
The sorted <see cref="T:System.Span`1" /> to search.
comparable
The <see cref="T:System.IComparable`1" /> to use when comparing.
public static
int
BinarySearch​(ReadOnlySpan<​T> span,
T value,
TComparer comparer)
Searches an entire sorted <see cref="T:System.ReadOnlySpan`1" /> for a specified value using the specified <typeparamref name="TComparer" /> generic type.
Returns The zero-based index of <paramref name="value" /> in the sorted <paramref name="span" /> , if <paramref name="value" /> is found; otherwise, a negative number that is the bitwise complement of the index of the next element that is larger than <paramref name="value" /> or, if there is no larger element, the bitwise complement of <see cref="P:System.ReadOnlySpan`1.Length" /> .
span
The sorted <see cref="T:System.ReadOnlySpan`1" /> to search.
value
The object to locate. The value can be <see langword="null" /> for reference types.
comparer
The <typeparamref name="TComparer" /> to use when comparing.
public static
int
BinarySearch​(ReadOnlySpan<​T> span,
TComparable comparable)
Searches an entire sorted <see cref="T:System.ReadOnlySpan`1" /> for a value using the specified <typeparamref name="TComparable" /> generic type.
Returns The zero-based index of <paramref name="comparable" /> in the sorted <paramref name="span" /> , if <paramref name="comparable" /> is found; otherwise, a negative number that is the bitwise complement of the index of the next element that is larger than <paramref name="comparable" /> or, if there is no larger element, the bitwise complement of <see cref="P:System.ReadOnlySpan`1.Length" /> .
span
The sorted <see cref="T:System.ReadOnlySpan`1" /> to search.
comparable
The <typeparamref name="TComparable" /> to use when comparing.
public static
int
BinarySearch​(Span<​T> span,
T value,
TComparer comparer)
Searches an entire sorted <see cref="T:System.Span`1" /> for a specified value using the specified <typeparamref name="TComparer" /> generic type.
Returns The zero-based index of <paramref name="value" /> in the sorted <paramref name="span" /> , if <paramref name="value" /> is found; otherwise, a negative number that is the bitwise complement of the index of the next element that is larger than <paramref name="value" /> or, if there is no larger element, the bitwise complement of <see cref="P:System.Span`1.Length" /> .
span
The sorted <see cref="T:System.Span`1" /> to search.
value
The object to locate. The value can be <see langword="null" /> for reference types.
comparer
The <typeparamref name="TComparer" /> to use when comparing.
public static
int
BinarySearch​(Span<​T> span,
TComparable comparable)
Searches an entire sorted <see cref="T:System.Span`1" /> for a value using the specified <typeparamref name="TComparable" /> generic type.
Returns The zero-based index of <paramref name="comparable" /> in the sorted <paramref name="span" /> , if <paramref name="comparable" /> is found; otherwise, a negative number that is the bitwise complement of the index of the next element that is larger than <paramref name="comparable" /> or, if there is no larger element, the bitwise complement of <see cref="P:System.Span`1.Length" /> .
span
The sorted <see cref="T:System.Span`1" /> to search.
comparable
The <typeparamref name="TComparable" /> to use when comparing.
public static
int
CommonPrefixLength​(Span<​T> span,
ReadOnlySpan<​T> other)
Finds the length of any common prefix shared between <paramref name="span" /> and <paramref name="other" /> .
Returns The length of the common prefix shared by the two spans. If there's no shared prefix, 0 is returned.
span
The first sequence to compare.
other
The second sequence to compare.
public static
int
CommonPrefixLength​(Span<​T> span,
ReadOnlySpan<​T> other,
IEqualityComparer?<​T> comparer)
Finds the length of any common prefix shared between <paramref name="span" /> and <paramref name="other" /> .
Returns The length of the common prefix shared by the two spans. If there's no shared prefix, 0 is returned.
span
The first sequence to compare.
other
The second sequence to compare.
comparer
The <see cref="T:System.Collections.Generic.IEqualityComparer`1" /> implementation to use when comparing elements, or <see langword="null" /> to use the default <see cref="T:System.Collections.Generic.IEqualityComparer`1" /> for the type of an element.
public static
int
CommonPrefixLength​(ReadOnlySpan<​T> span,
ReadOnlySpan<​T> other)
Finds the length of any common prefix shared between <paramref name="span" /> and <paramref name="other" /> .
Returns The length of the common prefix shared by the two spans. If there's no shared prefix, 0 is returned.
span
The first sequence to compare.
other
The second sequence to compare.
public static
int
CommonPrefixLength​(ReadOnlySpan<​T> span,
ReadOnlySpan<​T> other,
IEqualityComparer?<​T> comparer)
Determines the length of any common prefix shared between <paramref name="span" /> and <paramref name="other" /> .
Returns The length of the common prefix shared by the two spans. If there's no shared prefix, 0 is returned.
span
The first sequence to compare.
other
The second sequence to compare.
comparer
The <see cref="T:System.Collections.Generic.IEqualityComparer`1" /> implementation to use when comparing elements, or <see langword="null" /> to use the default <see cref="T:System.Collections.Generic.IEqualityComparer`1" /> for the type of an element.
public static
int
CompareTo​(ReadOnlySpan<​char> span,
ReadOnlySpan<​char> other,
StringComparison comparisonType)
Compares one character span with another using a specified string comparison, and returns an integer that indicates their relative position in the sort order.
Returns A signed integer that indicates the relative order of <paramref name="span" /> and <paramref name="other" /> : <br /> - If less than 0, <paramref name="span" /> precedes than <paramref name="other" /> . <br /> - If 0, <paramref name="span" /> equals <paramref name="other" /> . <br /> - If greater than 0, <paramref name="span" /> follows <paramref name="other" /> .
span
The source span.
other
The value to compare with the source span.
comparisonType
An enumeration value that determines how <paramref name="span" /> and <paramref name="other" /> are compared.
public static
bool
Contains​(ReadOnlySpan<​char> span,
ReadOnlySpan<​char> value,
StringComparison comparisonType)
Indicates whether a specified value occurs within a read-only character span.
Returns <see langword="true" /> if <paramref name="value" /> occurs within the span, <see langword="false" /> otherwise.
span
The source span.
value
The value to seek within the source span.
comparisonType
An enumeration value that determines how the characters in <paramref name="span" /> and <paramref name="value" /> are compared.
public static
bool
Contains​(ReadOnlySpan<​T> span,
T value)
Indicates whether a specified value is found in a read-only span.
Returns <see langword="true" /> if found, <see langword="false" /> otherwise.
span
The span to search.
value
The value to search for.
public static
bool
Contains​(ReadOnlySpan<​T> span,
T value,
IEqualityComparer?<​T> comparer = null)
Searches for the specified value and returns <see langword="true" /> if found. If not found, returns <see langword="false" /> .
span
The span to search.
value
The value to search for.
comparer
The <see cref="T:System.Collections.Generic.IEqualityComparer`1" /> implementation to use when comparing elements, or <see langword="null" /> to use the default <see cref="T:System.Collections.Generic.IEqualityComparer`1" /> for the type of an element.
public static
bool
Contains​(Span<​T> span,
T value)
Indicates whether a specified value is found in a span.
Returns <see langword="true" /> if found, <see langword="false" /> otherwise.
span
The span to search.
value
The value to search for.
public static
bool
ContainsAny​(ReadOnlySpan<​char> span,
SearchValues<​string> values)
Searches for any occurrence of any of the specified substring <paramref name="values" /> .
Returns <see langword="true" /> if found. If not found, returns <see langword="false" /> .
span
The span to search.
values
The set of values to search for.
public static
bool
ContainsAny​(Span<​char> span,
SearchValues<​string> values)
Searches for any occurrence of any of the specified substring <code data-dev-comment-type="paramref">values</code> .
Returns <code data-dev-comment-type="langword">true</code> if found. If not found, returns <code data-dev-comment-type="langword">false</code> .
span
The span to search.
values
The set of values to search for.
public static
bool
ContainsAny​(ReadOnlySpan<​T> span,
SearchValues<​T> values)
Searches for an occurrence of any of the specified <paramref name="values" /> .
Returns <see langword="true" /> if found. If not found, returns <see langword="false" /> .
span
The span to search.
values
The set of values to search for.
public static
bool
ContainsAny​(ReadOnlySpan<​T> span,
ReadOnlySpan<​T> values)
Searches for an occurrence of any of the specified <paramref name="values" /> .
Returns <see langword="true" /> if found. If not found, returns <see langword="false" /> .
span
The span to search.
values
The set of values to search for.
public static
bool
ContainsAny​(ReadOnlySpan<​T> span,
ReadOnlySpan<​T> values,
IEqualityComparer?<​T> comparer = null)
Searches for any occurrence of any of the specified <paramref name="values" /> and returns <see langword="true" /> if found. If not found, returns <see langword="false" /> .
span
The span to search.
values
The set of values to search for.
comparer
The comparer to use. If <see langword="null" /> , <see cref="P:System.Collections.Generic.EqualityComparer`1.Default" /> is used.
public static
bool
ContainsAny​(ReadOnlySpan<​T> span,
T value0,
T value1)
Searches for an occurrence of <paramref name="value0" /> or <paramref name="value1" /> .
Returns <see langword="true" /> if found. If not found, returns <see langword="false" /> .
span
The span to search.
value0
The first value to search for.
value1
The second value to search for.
public static
bool
ContainsAny​(ReadOnlySpan<​T> span,
T value0,
T value1,
IEqualityComparer?<​T> comparer = null)
Searches for an occurrence of either of the specified values.
Returns <see langword="true" /> if an occurrence of either value is found; otherwise <see langword="false" /> .
span
The span to search.
value0
The first value to search for.
value1
The second value to search for.
comparer
The <see cref="T:System.Collections.Generic.IEqualityComparer`1" /> implementation to use when comparing elements, or <see langword="null" /> to use the default <see cref="T:System.Collections.Generic.IEqualityComparer`1" /> for the type of an element.
public static
bool
ContainsAny​(ReadOnlySpan<​T> span,
T value0,
T value1,
T value2)
Searches for an occurrence of <paramref name="value0" /> , <paramref name="value1" /> , or <paramref name="value2" /> in the specified span.
Returns <see langword="true" /> if any of the values is found; otherwise, <see langword="false" /> .
span
The span to search.
value0
The first value to search for.
value1
The second value to search for.
value2
The third value to search for.
public static
bool
ContainsAny​(ReadOnlySpan<​T> span,
T value0,
T value1,
T value2,
IEqualityComparer?<​T> comparer = null)
Searches for any occurrence of the specified values in the specified span.
Returns <see langword="true" /> if any of the values is found; otherwise, <see langword="false" />
span
The span to search.
value0
The first value to search for.
value1
The second value to search for.
value2
The third value to search for.
comparer
The <see cref="T:System.Collections.Generic.IEqualityComparer`1" /> implementation to use when comparing elements, or <see langword="null" /> to use the default <see cref="T:System.Collections.Generic.IEqualityComparer`1" /> for the type of an element.
public static
bool
ContainsAny​(Span<​T> span,
SearchValues<​T> values)
Searches for an occurrence of any of the specified <paramref name="values" /> and returns <see langword="true" /> if found. If not found, returns <see langword="false" /> .
Returns <code data-dev-comment-type="langword">true</code> if found. If not found, returns <code data-dev-comment-type="langword">false</code> .
span
The span to search.
values
The set of values to search for.
public static
bool
ContainsAny​(Span<​T> span,
ReadOnlySpan<​T> values)
Searches for an occurrence of any of the specified <paramref name="values" /> and returns <see langword="true" /> if found. If not found, returns <see langword="false" /> .
Returns <code data-dev-comment-type="langword">true</code> if found. If not found, returns <code data-dev-comment-type="langword">false</code> .
span
The span to search.
values
The set of values to search for.
public static
bool
ContainsAny​(Span<​T> span,
T value0,
T value1)
Searches for an occurrence of <paramref name="value0" /> or <paramref name="value1" /> , and returns <see langword="true" /> if found. If not found, returns <see langword="false" /> .
Returns <code data-dev-comment-type="langword">true</code> if found. If not found, returns <code data-dev-comment-type="langword">false</code> .
span
The span to search.
value0
The first value to search for.
value1
The second value to search for.
public static
bool
ContainsAny​(Span<​T> span,
T value0,
T value1,
T value2)
Searches for an occurrence of <paramref name="value0" /> , <paramref name="value1" /> , or <paramref name="value2" /> in the specified span.
Returns <see langword="true" /> if any of the values is found; otherwise, <see langword="false" /> .
span
The span to search.
value0
The first value to search for.
value1
The second value to search for.
value2
The third value to search for.
public static
bool
ContainsAnyExcept​(ReadOnlySpan<​T> span,
SearchValues<​T> values)
Searches the specified span for any value other than the specified <paramref name="values" /> .
Returns <see langword="true" /> if any value other than those in <paramref name="values" /> is present in the span. If all of the span's values are in <paramref name="values" /> , returns <see langword="false" /> .
span
The span to search.
values
The set of values to exclude from the search.
public static
bool
ContainsAnyExcept​(ReadOnlySpan<​T> span,
ReadOnlySpan<​T> values)
Searches the specified span for any value other than the specified <paramref name="values" /> .
Returns <see langword="true" /> if any value other than those in <paramref name="values" /> is present in the span. If all of the span's values are in <paramref name="values" /> , returns <see langword="false" /> .
span
The span to search.
values
The set of values to exclude from the search.
public static
bool
ContainsAnyExcept​(ReadOnlySpan<​T> span,
ReadOnlySpan<​T> values,
IEqualityComparer?<​T> comparer = null)
Searches the specified span for any value other than the specified <paramref name="values" /> .
Returns <see langword="true" /> if any value other than those in <paramref name="values" /> is present in the span. If all of the span's values are in <paramref name="values" /> , returns <see langword="false" /> .
span
The span to search.
values
The values to avoid.
comparer
The <see cref="T:System.Collections.Generic.IEqualityComparer`1" /> implementation to use when comparing elements, or <see langword="null" /> to use the default <see cref="T:System.Collections.Generic.IEqualityComparer`1" /> for the type of an element.
public static
bool
ContainsAnyExcept​(ReadOnlySpan<​T> span,
T value)
Searches the specified span for any value other than the specified <paramref name="value" /> .
Returns <see langword="true" /> if any value other than <paramref name="value" /> is present in the span. If all of the span's values are <paramref name="value" /> , returns <see langword="false" /> .
span
The span to search.
value
The value to exclude from the search.
public static
bool
ContainsAnyExcept​(ReadOnlySpan<​T> span,
T value,
IEqualityComparer?<​T> comparer = null)
Searches the specified span for any value other than <paramref name="value" /> .
Returns <see langword="true" /> if any value other than <paramref name="value" /> is present in the span. If all of the span's values are <paramref name="value" /> , returns <see langword="false" /> .
span
The span to search.
value
The value to avoid.
comparer
The <see cref="T:System.Collections.Generic.IEqualityComparer`1" /> implementation to use when comparing elements, or <see langword="null" /> to use the default <see cref="T:System.Collections.Generic.IEqualityComparer`1" /> for the type of an element.
public static
bool
ContainsAnyExcept​(ReadOnlySpan<​T> span,
T value0,
T value1)
Searches the specified span for any value other than <paramref name="value0" /> or <paramref name="value1" /> .
Returns <see langword="true" /> if any value other than <paramref name="value0" /> or <paramref name="value1" /> is present in the span. If all of the span's values are <paramref name="value0" /> or <paramref name="value1" /> , returns <see langword="false" /> .
span
The span to search.
value0
The first value to exclude from the search.
value1
The second value to exclude from the search.
public static
bool
ContainsAnyExcept​(ReadOnlySpan<​T> span,
T value0,
T value1,
IEqualityComparer?<​T> comparer = null)
Searches for any value other than <paramref name="value0" /> or <paramref name="value1" /> .
Returns <see langword="true" /> if any value other than <paramref name="value0" /> and <paramref name="value1" /> is present in the span. If all of the span's values are <paramref name="value0" /> or <paramref name="value1" /> , returns <see langword="false" /> .
span
The span to search.
value0
The first value to avoid.
value1
The second value to avoid.
comparer
The <see cref="T:System.Collections.Generic.IEqualityComparer`1" /> implementation to use when comparing elements, or <see langword="null" /> to use the default <see cref="T:System.Collections.Generic.IEqualityComparer`1" /> for the type of an element.
public static
bool
ContainsAnyExcept​(ReadOnlySpan<​T> span,
T value0,
T value1,
T value2)
Searches for any value other than <paramref name="value0" /> , <paramref name="value1" /> , or <paramref name="value2" /> .
Returns <see langword="true" /> if any value other than <paramref name="value0" /> , <paramref name="value1" /> , or <paramref name="value2" /> is present in the span. If all of the span's values are <paramref name="value0" /> , <paramref name="value1" /> , or <paramref name="value2" /> , returns <see langword="false" /> .
span
The span to search.
value0
The first value to exclude from the search.
value1
The second value to exclude from the search.
value2
The third value to exclude from the search.
public static
bool
ContainsAnyExcept​(ReadOnlySpan<​T> span,
T value0,
T value1,
T value2,
IEqualityComparer?<​T> comparer = null)
Searches for any value other than <paramref name="value0" /> , <paramref name="value1" /> , or <paramref name="value2" /> .
Returns <see langword="true" /> if any value other than <paramref name="value0" /> , <paramref name="value1" /> , and <paramref name="value2" /> is present in the span. If all of the span's values are <paramref name="value0" /> , <paramref name="value1" /> , or <paramref name="value2" /> , returns <see langword="false" /> .
span
The span to search.
value0
The first value to avoid.
value1
The second value to avoid.
value2
The third value to avoid.
comparer
The <see cref="T:System.Collections.Generic.IEqualityComparer`1" /> implementation to use when comparing elements, or <see langword="null" /> to use the default <see cref="T:System.Collections.Generic.IEqualityComparer`1" /> for the type of an element.
public static
bool
ContainsAnyExcept​(Span<​T> span,
SearchValues<​T> values)
Searches the specified span for any value other than the specified <paramref name="values" /> .
Returns <see langword="true" /> if any value other than those in <paramref name="values" /> is present in the span. If all of the span's values are in <paramref name="values" /> , returns <see langword="false" /> .
span
The span to search.
values
The set of values to exclude from the search.
public static
bool
ContainsAnyExcept​(Span<​T> span,
ReadOnlySpan<​T> values)
Searches the specified span for any value other than the specified <paramref name="values" /> .
Returns <see langword="true" /> if any value other than those in <paramref name="values" /> is present in the span. If all of the span's values are in <paramref name="values" /> , returns <see langword="false" /> .
span
The span to search.
values
The set of values to exclude from the search.
public static
bool
ContainsAnyExcept​(Span<​T> span,
T value)
Searches the specified span for any value other than the specified <paramref name="value" /> .
Returns <see langword="true" /> if any value other than <paramref name="value" /> is present in the span. If all of the span's values are <paramref name="value" /> , returns <see langword="false" /> .
span
The span to search.
value
The value to exclude from the search.
public static
bool
ContainsAnyExcept​(Span<​T> span,
T value0,
T value1)
Searches the specified span for any value other than <paramref name="value0" /> or <paramref name="value1" /> .
Returns <see langword="true" /> if any value other than <paramref name="value0" /> or <paramref name="value1" /> is present in the span. If all of the span's values are <paramref name="value0" /> or <paramref name="value1" /> , returns <see langword="false" /> .
span
The span to search.
value0
The first value to exclude from the search.
value1
The second value to exclude from the search.
public static
bool
ContainsAnyExcept​(Span<​T> span,
T value0,
T value1,
T value2)
Searches for any value other than <paramref name="value0" /> , <paramref name="value1" /> , or <paramref name="value2" /> .
Returns <see langword="true" /> if any value other than <paramref name="value0" /> , <paramref name="value1" /> , or <paramref name="value2" /> is present in the span. If all of the span's values are <paramref name="value0" /> , <paramref name="value1" /> , or <paramref name="value2" /> , returns <see langword="false" /> .
span
The span to search.
value0
The first value to exclude from the search.
value1
The second value to exclude from the search.
value2
The third value to exclude from the search.
public static
bool
ContainsAnyExceptInRange​(ReadOnlySpan<​T> span,
T lowInclusive,
T highInclusive)
Searches for any value outside of the range between <paramref name="lowInclusive" /> and <paramref name="highInclusive" /> , inclusive.
Returns <see langword="true" /> if any value other than those in the specified range is present in the span. If all of the span's values are inside of the specified range, returns <see langword="false" /> .
span
The span to search.
lowInclusive
The lower bound, inclusive, of the excluded range.
highInclusive
The upper bound, inclusive, of the excluded range.
public static
bool
ContainsAnyExceptInRange​(Span<​T> span,
T lowInclusive,
T highInclusive)
Searches for any value outside of the range between <paramref name="lowInclusive" /> and <paramref name="highInclusive" /> , inclusive.
Returns <see langword="true" /> if any value other than those in the specified range is present in the span.
If all of the values are inside of the specified range, returns <see langword="false" /> .
span
The span to search.
lowInclusive
The lower bound, inclusive, of the excluded range.
highInclusive
The upper bound, inclusive, of the excluded range.
public static
bool
ContainsAnyInRange​(ReadOnlySpan<​T> span,
T lowInclusive,
T highInclusive)
Searches for any value in the range between <paramref name="lowInclusive" /> and <paramref name="highInclusive" /> , inclusive.
Returns <see langword="true" /> if found. If not found, returns <see langword="false" /> .
span
The span to search.
lowInclusive
The lower bound, inclusive, of the range for which to search.
highInclusive
The upper bound, inclusive, of the range for which to search.
public static
bool
ContainsAnyInRange​(Span<​T> span,
T lowInclusive,
T highInclusive)
Searches for any value in the range between <paramref name="lowInclusive" /> and <paramref name="highInclusive" /> , inclusive, and returns <see langword="true" /> if found. If not found, returns <see langword="false" /> .
Returns <code data-dev-comment-type="langword">true</code> if found. If not found, returns <code data-dev-comment-type="langword">false</code> .
span
The span to search.
lowInclusive
The lower bound, inclusive, of the range for which to search.
highInclusive
The upper bound, inclusive, of the range for which to search.
public static
void
CopyTo​(T[] source,
Memory<​T> destination)
Copies the contents of the array into a memory region.
source
The array to copy items from.
destination
The memory to copy items into.
public static
void
CopyTo​(T[] source,
Span<​T> destination)
Copies the contents of the array into the span.
source
The array to copy items from.
destination
The span to copy items into.
public static
int
Count​(Span<​T> span,
T value)
Counts the number of times the specified <paramref name="value" /> occurs in the <paramref name="span" /> .
Returns The number of times <paramref name="value" /> was found in the <paramref name="span" /> .
span
The span to search.
value
The value for which to search.
public static
int
Count​(ReadOnlySpan<​T> span,
T value)
Counts the number of times the specified <paramref name="value" /> occurs in the <paramref name="span" /> .
Returns The number of times <paramref name="value" /> was found in the <paramref name="span" /> .
span
The span to search.
value
The value for which to search.
public static
int
Count​(ReadOnlySpan<​T> span,
T value,
IEqualityComparer?<​T> comparer = null)
Counts the number of times the specified <paramref name="value" /> occurs in the <paramref name="span" /> .
Returns The number of times <paramref name="value" /> was found in the <paramref name="span" /> .
span
The span to search.
value
The value to search for.
comparer
The <see cref="T:System.Collections.Generic.IEqualityComparer`1" /> implementation to use when comparing elements, or <see langword="null" /> to use the default <see cref="T:System.Collections.Generic.IEqualityComparer`1" /> for the type of an element.
public static
int
Count​(Span<​T> span,
ReadOnlySpan<​T> value)
Counts the number of times the specified <paramref name="value" /> occurs in the <paramref name="span" /> .
Returns The number of times <paramref name="value" /> was found in the <paramref name="span" /> .
span
The span to search.
value
The value for which to search.
public static
int
Count​(ReadOnlySpan<​T> span,
ReadOnlySpan<​T> value)
Counts the number of times <paramref name="value" /> occurs in <paramref name="span" /> .
Returns The number of times <paramref name="value" /> was found in <paramref name="span" /> .
span
The span to search.
value
The value for which to search.
public static
int
Count​(ReadOnlySpan<​T> span,
ReadOnlySpan<​T> value,
IEqualityComparer?<​T> comparer = null)
Counts the number of times the specified <paramref name="value" /> occurs in the <paramref name="span" /> .
Returns The number of times <paramref name="value" /> was found in the <paramref name="span" /> .
span
The span to search.
value
The value for which to search.
comparer
The <see cref="T:System.Collections.Generic.IEqualityComparer`1" /> implementation to use when comparing elements, or <see langword="null" /> to use the default <see cref="T:System.Collections.Generic.IEqualityComparer`1" /> for the type of an element.
public static
int
CountAny​(ReadOnlySpan<​T> span,
SearchValues<​T> values)
Counts the number of times any of the specified <paramref name="values" /> occurs in the <paramref name="span" /> .
Returns The number of times any of the <typeparamref name="T" /> elements in <paramref name="values" /> was found in the <paramref name="span" /> .
span
The span to search.
values
The set of values for which to search.
public static
int
CountAny​(ReadOnlySpan<​T> span,
ReadOnlySpan<​T> values)
Counts the number of times any of the specified <paramref name="values" /> occurs in the <paramref name="span" /> .
Returns The number of times any of the <typeparamref name="T" /> elements in <paramref name="values" /> was found in the <paramref name="span" /> .
span
The span to search.
values
The set of values for which to search.
public static
int
CountAny​(ReadOnlySpan<​T> span,
ReadOnlySpan<​T> values,
IEqualityComparer?<​T> comparer = null)
Counts the number of times any of the specified <paramref name="values" /> occurs in the <paramref name="span" /> .
Returns The number of times any of the <typeparamref name="T" /> elements in <paramref name="values" /> was found in the <paramref name="span" /> .
span
The span to search.
values
The set of values for which to search.
comparer
<para>The <see cref="T:System.Collections.Generic.IEqualityComparer`1" /> implementation to use when comparing elements, or <see langword="null" /> to use the default <see cref="T:System.Collections.Generic.IEqualityComparer`1" /> for the type of an element.</para>
public static
bool
EndsWith​(ReadOnlySpan<​char> span,
ReadOnlySpan<​char> value,
StringComparison comparisonType)
Determines whether the end of the <paramref name="span" /> matches the specified <paramref name="value" /> when compared using the specified <paramref name="comparisonType" /> option.
Returns <see langword="true" /> if <paramref name="value" /> matches the end of <paramref name="span" /> ; otherwise, <see langword="false" /> .
span
The source span.
value
The sequence to compare to the end of the source span.
comparisonType
An enumeration value that determines how <paramref name="span" /> and <paramref name="value" /> are compared.
public static
bool
EndsWith​(ReadOnlySpan<​T> span,
ReadOnlySpan<​T> value)
Determines whether the specified sequence appears at the end of a read-only span.
Returns <see langword="true" /> if <paramref name="value" /> matches the end of <paramref name="span" /> ; otherwise, <see langword="false" /> .
span
The source span.
value
The sequence to compare to the end of the source span.
public static
bool
EndsWith​(ReadOnlySpan<​T> span,
ReadOnlySpan<​T> value,
IEqualityComparer?<​T> comparer = null)
Determines whether the specified sequence appears at the end of the read-only span.
span
The source span.
value
The sequence to compare to the end of <paramref name="span" /> .
comparer
The <see cref="T:System.Collections.Generic.IEqualityComparer`1" /> implementation to use when comparing elements, or <see langword="null" /> to use the default <see cref="T:System.Collections.Generic.IEqualityComparer`1" /> for the type of an element.
public static
bool
EndsWith​(Span<​T> span,
ReadOnlySpan<​T> value)
Determines whether the specified sequence appears at the end of a span.
Returns <see langword="true" /> if <paramref name="value" /> matches the end of <paramref name="span" /> ; otherwise, <see langword="false" /> .
span
The source span.
value
The sequence to compare to the end of the source span.
public static
bool
EndsWith​(ReadOnlySpan<​T> span,
T value)
Determines whether the specified value appears at the end of the span.
Returns <see langword="true" /> if <paramref name="value" /> matches the end of <paramref name="span" /> ; otherwise, <see langword="false" /> .
span
The span to search.
value
The value to compare.
public static
bool
EndsWith​(ReadOnlySpan<​T> span,
T value,
IEqualityComparer?<​T> comparer = null)
Determines whether the specified value appears at the end of the span.
Returns <see langword="true" /> if <paramref name="value" /> matches the end of <paramref name="span" /> ; otherwise, <see langword="false" /> .
span
The span to search.
value
The value to compare.
comparer
The <see cref="T:System.Collections.Generic.IEqualityComparer`1" /> implementation to use when comparing elements, or <see langword="null" /> to use the default <see cref="T:System.Collections.Generic.IEqualityComparer`1" /> for the type of an element.
public static
SpanLineEnumerator
EnumerateLines​(ReadOnlySpan<​char> span)
Returns an enumeration of lines over the provided span.
Returns An enumeration of lines.
span
A span containing the lines to enumerate.
public static
SpanLineEnumerator
EnumerateLines​(Span<​char> span)
Returns an enumeration of lines over the provided span.
Returns An enumeration of lines.
span
A span containing the lines to enumerate.
public static
SpanRuneEnumerator
EnumerateRunes​(ReadOnlySpan<​char> span)
Returns an enumeration of <see cref="T:System.Text.Rune" /> from the provided read-only span.
Returns A rune enumerator.
span
The source span.
public static
SpanRuneEnumerator
EnumerateRunes​(Span<​char> span)
Returns an enumeration of <see cref="T:System.Text.Rune" /> from the provided span.
Returns A rune enumerator.
span
The source span.
public static
bool
Equals​(ReadOnlySpan<​char> span,
ReadOnlySpan<​char> other,
StringComparison comparisonType)
Determines whether this <paramref name="span" /> and the specified <paramref name="other" /> span have the same characters when compared using the specified <paramref name="comparisonType" /> option.
Returns <see langword="true" /> if equal, <see langword="false" /> otherwise.
span
The source span.
other
The value to compare with the source span.
comparisonType
An enumeration value that determines how <paramref name="span" /> and <paramref name="other" /> are compared.
public static
int
IndexOf​(ReadOnlySpan<​char> span,
ReadOnlySpan<​char> value,
StringComparison comparisonType)
Reports the zero-based index of the first occurrence of the specified <paramref name="value" /> in the current <paramref name="span" /> .
Returns The index of the occurrence of the value in the span.
span
The source span.
value
The value to seek within the source span.
comparisonType
An enumeration value that determines how <paramref name="span" /> and <paramref name="value" /> are compared.
public static
int
IndexOfAny​(ReadOnlySpan<​char> span,
SearchValues<​string> values)
Searches for the first index of any of the specified substring values.
Returns The first index of any of the specified values, or -1 if none are found.
span
The span to search.
values
The set of values to search for.
public static
int
IndexOfAny​(Span<​char> span,
SearchValues<​string> values)
Searches for the first index of any of the specified substring values.
Returns The first index of any of the specified values, or -1 if none are found.
span
The span to search.
values
The set of values to search for.
public static
int
IndexOfAny​(ReadOnlySpan<​T> span,
SearchValues<​T> values)
Searches for the first index of any of the specified values.
Returns The first index of any of the specified values, or -1 if none are found.
span
The span to search.
values
The set of values to search for.
public static
int
IndexOfAny​(ReadOnlySpan<​T> span,
ReadOnlySpan<​T> values)
Searches for the first index of any of the specified values.
Returns The first index of the occurrence of any of the values in the span. If not found, returns -1.
span
The span to search.
values
The set of values to search for.
public static
int
IndexOfAny​(ReadOnlySpan<​T> span,
ReadOnlySpan<​T> values,
IEqualityComparer?<​T> comparer = null)
Searches for the first index of any of the specified values.
Returns The first index of any of the specified values. If not found, returns -1.
span
The span to search.
values
The set of values to search for.
comparer
The <see cref="T:System.Collections.Generic.IEqualityComparer`1" /> implementation to use when comparing elements, or <see langword="null" /> to use the default <see cref="T:System.Collections.Generic.IEqualityComparer`1" /> for the type of an element.
public static
int
IndexOfAny​(ReadOnlySpan<​T> span,
T value0,
T value1)
Searches for the first index of either of the specified values.
Returns The first index of the occurrence of any of the values in the span. If not found, returns -1.
span
The span to search.
value0
The first value to search for.
value1
The second value to search for.
public static
int
IndexOfAny​(ReadOnlySpan<​T> span,
T value0,
T value1,
IEqualityComparer?<​T> comparer = null)
Searches for the first index of any of the specified values.
Returns The first index of any of the specified values. If not found, returns -1.
span
The span to search.
value0
The first value to search for.
value1
The second value to search for.
comparer
The <see cref="T:System.Collections.Generic.IEqualityComparer`1" /> implementation to use when comparing elements, or <see langword="null" /> to use the default <see cref="T:System.Collections.Generic.IEqualityComparer`1" /> for the type of an element.
public static
int
IndexOfAny​(ReadOnlySpan<​T> span,
T value0,
T value1,
T value2)
Searches for the first index of any of the specified values.
Returns The first index of the occurrence of any of the values in the span. If not found, returns -1.
span
The span to search.
value0
The first value to search for.
value1
The second value to search for.
value2
The third value to search for.
public static
int
IndexOfAny​(ReadOnlySpan<​T> span,
T value0,
T value1,
T value2,
IEqualityComparer?<​T> comparer = null)
Searches for the first index of any of the specified values.
Returns The first index of any of the specified values. If not found, returns -1.
span
The span to search.
value0
The first value to search for.
value1
The second value to search for.
value2
The third value to search for.
comparer
The <see cref="T:System.Collections.Generic.IEqualityComparer`1" /> implementation to use when comparing elements, or <see langword="null" /> to use the default <see cref="T:System.Collections.Generic.IEqualityComparer`1" /> for the type of an element.
public static
int
IndexOfAny​(Span<​T> span,
SearchValues<​T> values)
Searches for the first index of any of the specified values.
Returns The first index of any of the specified values, or -1 if none are found.
span
The span to search.
values
The set of values to search for.
public static
int
IndexOfAny​(Span<​T> span,
ReadOnlySpan<​T> values)
Searches for the first index of any of the specified values.
Returns The first index of the occurrence of any of the values in the span. If not found, returns -1.
span
The span to search.
values
The set of values to search for.
public static
int
IndexOfAny​(Span<​T> span,
T value0,
T value1)
Searches for the first index of any of the specified values.
Returns The first index of the occurrence of any of the values in the span. If not found, returns -1.
span
The span to search.
value0
The first value to search for.
value1
The second value to search for.
public static
int
IndexOfAny​(Span<​T> span,
T value0,
T value1,
T value2)
Searches for the first index of any of the specified values.
Returns The first index of the occurrence of any of the values in the span. If not found, returns -1.
span
The span to search.
value0
The first value to search for.
value1
The second value to search for.
value2
The third value to search for.
public static
int
IndexOfAnyExcept​(Span<​T> span,
T value)
Searches for the first index of any value other than the specified <paramref name="value" /> .
Returns The index in the span of the first occurrence of any value other than <paramref name="value" /> .
If all of the values are <paramref name="value" /> , returns -1.
span
The span to search.
value
The value to avoid.
public static
int
IndexOfAnyExcept​(Span<​T> span,
T value0,
T value1)
Searches for the first index of any value other than the two specified values.
Returns The index in the span of the first occurrence of any value other than <paramref name="value0" /> and <paramref name="value1" /> . If all of the values are <paramref name="value0" /> or <paramref name="value1" /> , returns -1.
span
The span to search.
value0
The first value to avoid.
value1
The second value to avoid.
public static
int
IndexOfAnyExcept​(Span<​T> span,
T value0,
T value1,
T value2)
Searches for the first index of any value other than <paramref name="value0" /> , <paramref name="value1" /> , or <paramref name="value2" /> .
Returns The index in the span of the first occurrence of any value other than <paramref name="value0" /> , <paramref name="value1" /> , and <paramref name="value2" /> . If all of the values are <paramref name="value0" /> , <paramref name="value1" /> , and <paramref name="value2" /> , returns -1.
span
The span to search.
value0
The first value to avoid.
value1
The second value to avoid.
value2
The third value to avoid.
public static
int
IndexOfAnyExcept​(Span<​T> span,
SearchValues<​T> values)
Searches for the first index of any value other than the specified <paramref name="values" /> .
Returns The index in the span of the first occurrence of any value other than those in <paramref name="values" /> .
If all of the values are in <paramref name="values" /> , returns -1.
span
The span to search.
values
The values to exclude from the search.
public static
int
IndexOfAnyExcept​(Span<​T> span,
ReadOnlySpan<​T> values)
Searches for the first index of any value other than the specified <paramref name="values" /> .
Returns The index in the span of the first occurrence of any value other than those in <paramref name="values" /> .
If all of the values are in <paramref name="values" /> , returns -1.
span
The span to search.
values
The values to avoid.
public static
int
IndexOfAnyExcept​(ReadOnlySpan<​T> span,
T value)
Searches for the first index of any value other than the specified <paramref name="value" /> .
Returns The index in the span of the first occurrence of any value other than <paramref name="value" /> .
If all of the values are <paramref name="value" /> , returns -1.
span
The span to search.
value
The value to avoid.
public static
int
IndexOfAnyExcept​(ReadOnlySpan<​T> span,
T value,
IEqualityComparer?<​T> comparer = null)
Searches for the first index of any value other than the specified <paramref name="value" /> .
Returns The index in the span of the first occurrence of any value other than <paramref name="value" /> . If all of the values are <paramref name="value" /> , returns -1.
span
The span to search.
value
The value to avoid.
comparer
The <see cref="T:System.Collections.Generic.IEqualityComparer`1" /> implementation to use when comparing elements, or <see langword="null" /> to use the default <see cref="T:System.Collections.Generic.IEqualityComparer`1" /> for the type of an element.
public static
int
IndexOfAnyExcept​(ReadOnlySpan<​T> span,
T value0,
T value1)
Searches for the first index of any value other than the two specified values.
Returns The index in the span of the first occurrence of any value other than <paramref name="value0" /> and <paramref name="value1" /> . If all of the values are <paramref name="value0" /> or <paramref name="value1" /> , returns -1.
span
The span to search.
value0
The first value to avoid.
value1
The second value to avoid.
public static
int
IndexOfAnyExcept​(ReadOnlySpan<​T> span,
T value0,
T value1,
IEqualityComparer?<​T> comparer = null)
Searches for the first index of any value other than the two specified values.
Returns The index in the span of the first occurrence of any value other than <paramref name="value0" /> and <paramref name="value1" /> . If all of the values are <paramref name="value0" /> or <paramref name="value1" /> , returns -1.
span
The span to search.
value0
The first value to avoid.
value1
The second value to avoid.
comparer
The <see cref="T:System.Collections.Generic.IEqualityComparer`1" /> implementation to use when comparing elements, or <see langword="null" /> to use the default <see cref="T:System.Collections.Generic.IEqualityComparer`1" /> for the type of an element.
public static
int
IndexOfAnyExcept​(ReadOnlySpan<​T> span,
T value0,
T value1,
T value2)
Searches for the first index of any value other than <paramref name="value0" /> , <paramref name="value1" /> , or <paramref name="value2" /> .
Returns The index in the span of the first occurrence of any value other than <paramref name="value0" /> , <paramref name="value1" /> , and <paramref name="value2" /> . If all of the values are <paramref name="value0" /> , <paramref name="value1" /> , and <paramref name="value2" /> , returns -1.
span
The span to search.
value0
The first value to avoid.
value1
The second value to avoid.
value2
The third value to avoid.
public static
int
IndexOfAnyExcept​(ReadOnlySpan<​T> span,
T value0,
T value1,
T value2,
IEqualityComparer?<​T> comparer = null)
Searches for the first index of any value other than <paramref name="value0" /> , <paramref name="value1" /> , or <paramref name="value2" /> .
Returns <para>The index in the span of the first occurrence of any value other than <paramref name="value0" />, <paramref name="value1" />, and <paramref name="value2" />.</para> <para>If all of the values are <paramref name="value0" />, <paramref name="value1" />, and <paramref name="value2" />, returns -1.</para>
span
The span to search.
value0
The first value to avoid.
value1
The second value to avoid.
value2
The third value to avoid.
comparer
The <see cref="T:System.Collections.Generic.IEqualityComparer`1" /> implementation to use when comparing elements, or <see langword="null" /> to use the default <see cref="T:System.Collections.Generic.IEqualityComparer`1" /> for the type of an element.
public static
int
IndexOfAnyExcept​(ReadOnlySpan<​T> span,
SearchValues<​T> values)
Searches for the first index of any value other than the specified <paramref name="values" /> .
Returns The index in the span of the first occurrence of any value other than those in <paramref name="values" /> .
If all of the values are in <paramref name="values" /> , returns -1.
span
The span to search.
values
The values to exclude from the search.
public static
int
IndexOfAnyExcept​(ReadOnlySpan<​T> span,
ReadOnlySpan<​T> values)
Searches for the first index of any value other than the specified <paramref name="values" /> .
Returns The index in the span of the first occurrence of any value other than those in <paramref name="values" /> .
If all of the values are in <paramref name="values" /> , returns -1.
span
The span to search.
values
The values to avoid.
public static
int
IndexOfAnyExcept​(ReadOnlySpan<​T> span,
ReadOnlySpan<​T> values,
IEqualityComparer?<​T> comparer = null)
Searches for the first index of any value other than the specified <paramref name="values" /> .
Returns <para>The index in the span of the first occurrence of any value other than those in <paramref name="values" />.</para> <para>If all of the values are in <paramref name="values" />, returns -1.</para>
span
The span to search.
values
The values to avoid.
comparer
The <see cref="T:System.Collections.Generic.IEqualityComparer`1" /> implementation to use when comparing elements, or <see langword="null" /> to use the default <see cref="T:System.Collections.Generic.IEqualityComparer`1" /> for the type of an element.
public static
int
IndexOfAnyExceptInRange​(ReadOnlySpan<​T> span,
T lowInclusive,
T highInclusive)
Searches for the first index of any value outside of the range between <paramref name="lowInclusive" /> and <paramref name="highInclusive" /> , inclusive.
Returns The index in the span of the first occurrence of any value outside of the specified range.
If all of the values are inside of the specified range, returns -1.
span
The span to search.
lowInclusive
The lower bound, inclusive, of the excluded range.
highInclusive
The upper bound, inclusive, of the excluded range.
public static
int
IndexOfAnyExceptInRange​(Span<​T> span,
T lowInclusive,
T highInclusive)
Searches for the first index of any value outside of the range between <paramref name="lowInclusive" /> and <paramref name="highInclusive" /> , inclusive.
Returns The index in the span of the first occurrence of any value outside of the specified range.
If all of the values are inside of the specified range, returns -1.
span
The span to search.
lowInclusive
The lower bound, inclusive, of the excluded range.
highInclusive
The upper bound, inclusive, of the excluded range.
public static
int
IndexOf​(ReadOnlySpan<​T> span,
ReadOnlySpan<​T> value)
Searches for the specified sequence and returns the index of its first occurrence.
Returns The index of the occurrence of the value in the span. If not found, returns -1.
span
The span to search.
value
The sequence to search for.
public static
int
IndexOf​(ReadOnlySpan<​T> span,
ReadOnlySpan<​T> value,
IEqualityComparer?<​T> comparer = null)
Searches for the specified sequence and returns the index of its first occurrence.
Returns The index of the first occurrence of the specified sequence. If not found, returns -1.
span
The span to search.
value
The sequence to search for.
comparer
The <see cref="T:System.Collections.Generic.IEqualityComparer`1" /> implementation to use when comparing elements, or <see langword="null" /> to use the default <see cref="T:System.Collections.Generic.IEqualityComparer`1" /> for the type of an element.
public static
int
IndexOf​(ReadOnlySpan<​T> span,
T value)
Searches for the specified value and returns the index of its first occurrence.
Returns The index of the occurrence of the value in the span. If not found, returns -1.
span
The span to search.
value
The value to search for.
public static
int
IndexOf​(ReadOnlySpan<​T> span,
T value,
IEqualityComparer?<​T> comparer = null)
Searches for the specified value and returns the index of its first occurrence.
Returns The index of the first occurrence of the specified value. If not found, returns -1.
span
The span to search.
value
The value to search for.
comparer
The <see cref="T:System.Collections.Generic.IEqualityComparer`1" /> implementation to use when comparing elements, or <see langword="null" /> to use the default <see cref="T:System.Collections.Generic.IEqualityComparer`1" /> for the type of an element.
public static
int
IndexOf​(Span<​T> span,
ReadOnlySpan<​T> value)
Searches for the specified sequence and returns the index of its first occurrence.
Returns The index of the occurrence of the value in the span. If not found, returns -1.
span
The span to search.
value
The sequence to search for.
public static
int
IndexOf​(Span<​T> span,
T value)
Searches for the specified value and returns the index of its first occurrence.
Returns The index of the occurrence of the value in the span. If not found, returns -1.
span
The span to search.
value
The value to search for.
public static
int
IndexOfAnyInRange​(ReadOnlySpan<​T> span,
T lowInclusive,
T highInclusive)
Searches for the first index of any value in the range between <paramref name="lowInclusive" /> and <paramref name="highInclusive" /> , inclusive.
Returns The index in the span of the first occurrence of any value in the specified range.
If all of the values are outside of the specified range, returns -1.
span
The span to search.
lowInclusive
The lower bound, inclusive, of the range for which to search.
highInclusive
The upper bound, inclusive, of the range for which to search.
public static
int
IndexOfAnyInRange​(Span<​T> span,
T lowInclusive,
T highInclusive)
Searches for the first index of any value in the range between <paramref name="lowInclusive" /> and <paramref name="highInclusive" /> , inclusive.
Returns The index in the span of the first occurrence of any value in the specified range.
If all of the values are outside of the specified range, returns -1.
span
The span to search.
lowInclusive
The lower bound, inclusive, of the range for which to search.
highInclusive
The upper bound, inclusive, of the range for which to search.
public static
bool
IsWhiteSpace​(ReadOnlySpan<​char> span)
Indicates whether the specified span contains only whitespace characters.
Returns <see langword="true" /> if the span contains only whitespace characters, <see langword="false" /> otherwise.
span
The source span.
public static
int
LastIndexOf​(ReadOnlySpan<​char> span,
ReadOnlySpan<​char> value,
StringComparison comparisonType)
Reports the zero-based index of the last occurrence of the specified <paramref name="value" /> in the current <paramref name="span" /> .
Returns The index of the last occurrence of the value in the span.
span
The source span.
value
The value to seek within the source span.
comparisonType
An enumeration value that determines how <paramref name="span" /> and <paramref name="value" /> are compared.
public static
int
LastIndexOfAny​(ReadOnlySpan<​T> span,
SearchValues<​T> values)
Searches for the last index of any of the specified values.
Returns The last index of any of the specified values, or -1 if none are found.
span
The span to search.
values
The set of values to search for.
public static
int
LastIndexOfAny​(ReadOnlySpan<​T> span,
ReadOnlySpan<​T> values)
Searches for the last index of any of the specified values.
Returns The index of the last occurrence of any of the values in the span. If not found, returns -1.
span
The span to search.
values
The set of values to search for.
public static
int
LastIndexOfAny​(ReadOnlySpan<​T> span,
ReadOnlySpan<​T> values,
IEqualityComparer?<​T> comparer = null)
Searches for the last index of any of the specified values.
Returns The last index of any of the specified values, or -1 if none of the values are found.
span
The span to search.
values
The set of values to search for.
comparer
The <see cref="T:System.Collections.Generic.IEqualityComparer`1" /> implementation to use when comparing elements, or <see langword="null" /> to use the default <see cref="T:System.Collections.Generic.IEqualityComparer`1" /> for the type of an element.
public static
int
LastIndexOfAny​(ReadOnlySpan<​T> span,
T value0,
T value1)
Searches for the last index of any of the specified values.
Returns The index of the last occurrence of any of the values in the span. If not found, returns -1.
span
The span to search.
value0
The first value to search for.
value1
The second value to search for.
public static
int
LastIndexOfAny​(ReadOnlySpan<​T> span,
T value0,
T value1,
IEqualityComparer?<​T> comparer = null)
Searches for the last index of any of the specified values.
Returns The last index of any of the specified values. If none are found, returns -1.
span
The span to search.
value0
The first value to search for.
value1
The second value to search for.
comparer
The <see cref="T:System.Collections.Generic.IEqualityComparer`1" /> implementation to use when comparing elements, or <see langword="null" /> to use the default <see cref="T:System.Collections.Generic.IEqualityComparer`1" /> for the type of an element.
public static
int
LastIndexOfAny​(ReadOnlySpan<​T> span,
T value0,
T value1,
T value2)
Searches for the last index of any of the specified values.
Returns The index of the last occurrence of any of the values in the span. If not found, returns -1.
span
The span to search.
value0
The first value to search for.
value1
The second value to search for.
value2
The third value to search for.
public static
int
LastIndexOfAny​(ReadOnlySpan<​T> span,
T value0,
T value1,
T value2,
IEqualityComparer?<​T> comparer = null)
Searches for the last index of any of the specified values.
Returns The last index of any of the specified values, or -1 if none are found.
span
The span to search.
value0
The first value to search for.
value1
The second value to search for.
value2
The third value to search for.
comparer
The <see cref="T:System.Collections.Generic.IEqualityComparer`1" /> implementation to use when comparing elements, or <see langword="null" /> to use the default <see cref="T:System.Collections.Generic.IEqualityComparer`1" /> for the type of an element.
public static
int
LastIndexOfAny​(Span<​T> span,
SearchValues<​T> values)
Searches for the last index of any of the specified values.
Returns The last index of any of the specified values, or -1 if none are found.
span
The span to search.
values
The set of values to search for.
public static
int
LastIndexOfAny​(Span<​T> span,
ReadOnlySpan<​T> values)
Searches for the last index of any of the specified values.
Returns The index of the last occurrence of any of the values in the span. If not found, returns -1.
span
The span to search.
values
The set of values to search for.
public static
int
LastIndexOfAny​(Span<​T> span,
T value0,
T value1)
Searches for the last index of any of the specified values.
Returns The index of the last occurrence of any of the values in the span. If not found, returns -1.
span
The span to search.
value0
The first value to search for.
value1
The second value to search for.
public static
int
LastIndexOfAny​(Span<​T> span,
T value0,
T value1,
T value2)
Searches for the last index of any of the specified values.
Returns The index of the last occurrence of any of the values in the span. If not found, returns -1.
span
The span to search.
value0
The first value to search for.
value1
The second value to search for.
value2
The third value to search for.
public static
int
LastIndexOfAnyExcept​(Span<​T> span,
T value)
Searches for the last index of any value other than the specified <paramref name="value" /> .
Returns The index in the span of the last occurrence of any value other than <paramref name="value" /> .
If all of the values are <paramref name="value" /> , returns -1.
span
The span to search.
value
The value to avoid.
public static
int
LastIndexOfAnyExcept​(Span<​T> span,
T value0,
T value1)
Searches for the last index of any value other than the specified <paramref name="value0" /> or <paramref name="value1" /> .
Returns The index in the span of the last occurrence of any value other than <paramref name="value0" /> and <paramref name="value1" /> .
If all of the values are <paramref name="value0" /> or <paramref name="value1" /> , returns -1.
span
The span to search.
value0
The first value to avoid.
value1
The second value to avoid.
public static
int
LastIndexOfAnyExcept​(Span<​T> span,
T value0,
T value1,
T value2)
Searches for the last index of any value other than the specified <paramref name="value0" /> , <paramref name="value1" /> , or <paramref name="value2" /> .
Returns The index in the span of the last occurrence of any value other than <paramref name="value0" /> , <paramref name="value1" /> , and <paramref name="value2" /> .
If all of the values are <paramref name="value0" /> , <paramref name="value1" /> , and <paramref name="value2" /> , returns -1.
span
The span to search.
value0
The first value to avoid.
value1
The second value to avoid.
value2
The third value to avoid.
public static
int
LastIndexOfAnyExcept​(Span<​T> span,
SearchValues<​T> values)
Searches for the last index of any value other than the specified <paramref name="values" /> .
Returns The index in the span of the last occurrence of any value other than those in <paramref name="values" /> .
If all of the values are in <paramref name="values" /> , returns -1.
span
The span to search.
values
The values to exclude from the search.
public static
int
LastIndexOfAnyExcept​(Span<​T> span,
ReadOnlySpan<​T> values)
Searches for the last index of any value other than the specified <paramref name="values" /> .
Returns The index in the span of the last occurrence of any value other than those in <paramref name="values" /> .
If all of the values are in <paramref name="values" /> , returns -1.
span
The span to search.
values
The values to avoid.
public static
int
LastIndexOfAnyExcept​(ReadOnlySpan<​T> span,
T value)
Searches for the last index of any value other than the specified <paramref name="value" /> .
Returns The index in the span of the last occurrence of any value other than <paramref name="value" /> .
If all of the values are <paramref name="value" /> , returns -1.
span
The span to search.
value
The value to avoid.
public static
int
LastIndexOfAnyExcept​(ReadOnlySpan<​T> span,
T value,
IEqualityComparer?<​T> comparer = null)
Searches for the last index of any value other than the specified <paramref name="value" /> .
Returns <para>The index in the span of the last occurrence of any value other than <paramref name="value" />.</para> <para>If all of the values are <paramref name="value" />, returns -1.</para>
span
The span to search.
value
The value to avoid.
comparer
The <see cref="T:System.Collections.Generic.IEqualityComparer`1" /> implementation to use when comparing elements, or <see langword="null" /> to use the default <see cref="T:System.Collections.Generic.IEqualityComparer`1" /> for the type of an element.
public static
int
LastIndexOfAnyExcept​(ReadOnlySpan<​T> span,
T value0,
T value1)
Searches for the last index of any value other than the specified <paramref name="value0" /> or <paramref name="value1" /> .
Returns The index in the span of the last occurrence of any value other than <paramref name="value0" /> and <paramref name="value1" /> .
If all of the values are <paramref name="value0" /> or <paramref name="value1" /> , returns -1.
span
The span to search.
value0
The first value to avoid.
value1
The second value to avoid.
public static
int
LastIndexOfAnyExcept​(ReadOnlySpan<​T> span,
T value0,
T value1,
IEqualityComparer?<​T> comparer = null)
Searches for the last index of any value other than the specified <paramref name="value0" /> or <paramref name="value1" /> .
Returns <para>The index in the span of the last occurrence of any value other than <paramref name="value0" /> and <paramref name="value1" />.</para> <para>If all of the values are <paramref name="value0" /> or <paramref name="value1" />, returns -1.</para>
span
The span to search.
value0
The first value to avoid.
value1
The second value to avoid.
comparer
The <see cref="T:System.Collections.Generic.IEqualityComparer`1" /> implementation to use when comparing elements, or <see langword="null" /> to use the default <see cref="T:System.Collections.Generic.IEqualityComparer`1" /> for the type of an element.
public static
int
LastIndexOfAnyExcept​(ReadOnlySpan<​T> span,
T value0,
T value1,
T value2)
Searches for the last index of any value other than the specified <paramref name="value0" /> , <paramref name="value1" /> , or <paramref name="value2" /> .
Returns The index in the span of the last occurrence of any value other than <paramref name="value0" /> , <paramref name="value1" /> , and <paramref name="value2" /> .
If all of the values are <paramref name="value0" /> , <paramref name="value1" /> , and <paramref name="value2" /> , returns -1.
span
The span to search.
value0
The first value to avoid.
value1
The second value to avoid.
value2
The third value to avoid.
public static
int
LastIndexOfAnyExcept​(ReadOnlySpan<​T> span,
T value0,
T value1,
T value2,
IEqualityComparer?<​T> comparer = null)
Searches for the last index of any value other than the specified <paramref name="value0" /> , <paramref name="value1" /> , or <paramref name="value2" /> .
Returns <para>The index in the span of the last occurrence of any value other than <paramref name="value0" />, <paramref name="value1" />, and <paramref name="value2" />.</para> <para>If all of the values are <paramref name="value0" />, <paramref name="value1" />, and <paramref name="value2" />, returns -1.</para>
span
The span to search.
value0
The first value to avoid.
value1
The second value to avoid.
value2
The third value to avoid.
comparer
The <see cref="T:System.Collections.Generic.IEqualityComparer`1" /> implementation to use when comparing elements, or <see langword="null" /> to use the default <see cref="T:System.Collections.Generic.IEqualityComparer`1" /> for the type of an element.
public static
int
LastIndexOfAnyExcept​(ReadOnlySpan<​T> span,
SearchValues<​T> values)
Searches for the last index of any value other than the specified <paramref name="values" /> .
Returns The index in the span of the last occurrence of any value other than those in <paramref name="values" /> .
If all of the values are in <paramref name="values" /> , returns -1.
span
The span to search.
values
The values to exclude from the search.
public static
int
LastIndexOfAnyExcept​(ReadOnlySpan<​T> span,
ReadOnlySpan<​T> values)
Searches for the last index of any value other than the specified <paramref name="values" /> .
Returns The index in the span of the first occurrence of any value other than those in <paramref name="values" /> .
If all of the values are in <paramref name="values" /> , returns -1.
span
The span to search.
values
The values to avoid.
public static
int
LastIndexOfAnyExcept​(ReadOnlySpan<​T> span,
ReadOnlySpan<​T> values,
IEqualityComparer?<​T> comparer = null)
Searches for the last index of any value other than the specified <paramref name="values" /> .
Returns <para>The index in the span of the first occurrence of any value other than those in <paramref name="values" />.</para> <para>If all of the values are in <paramref name="values" />, returns -1.</para>
span
The span to search.
values
The values to avoid.
comparer
The <see cref="T:System.Collections.Generic.IEqualityComparer`1" /> implementation to use when comparing elements, or <see langword="null" /> to use the default <see cref="T:System.Collections.Generic.IEqualityComparer`1" /> for the type of an element.
public static
int
LastIndexOfAnyExceptInRange​(ReadOnlySpan<​T> span,
T lowInclusive,
T highInclusive)
Searches for the last index of any value outside of the range between <paramref name="lowInclusive" /> and <paramref name="highInclusive" /> , inclusive.
Returns The index in the span of the last occurrence of any value outside of the specified range.
If all of the values are inside of the specified range, returns -1.
span
The span to search.
lowInclusive
The lower bound, inclusive, of the excluded range.
highInclusive
The upper bound, inclusive, of the excluded range.
public static
int
LastIndexOfAnyExceptInRange​(Span<​T> span,
T lowInclusive,
T highInclusive)
Searches for the last index of any value outside of the range between <paramref name="lowInclusive" /> and <paramref name="highInclusive" /> , inclusive.
Returns The index in the span of the last occurrence of any value outside of the specified range.
If all of the values are inside of the specified range, returns -1.
span
The span to search.
lowInclusive
The lower bound, inclusive, of the excluded range.
highInclusive
The upper bound, inclusive, of the excluded range.
public static
int
LastIndexOf​(ReadOnlySpan<​T> span,
ReadOnlySpan<​T> value)
Searches for the specified sequence and returns the index of its last occurrence.
Returns The index of the last occurrence of the value in the span. If not found, returns -1.
span
The span to search.
value
The sequence to search for.
public static
int
LastIndexOf​(ReadOnlySpan<​T> span,
ReadOnlySpan<​T> value,
IEqualityComparer?<​T> comparer = null)
Searches for the specified sequence and returns the index of its last occurrence. If not found, returns -1.
span
The span to search.
value
The sequence to search for.
comparer
The <see cref="T:System.Collections.Generic.IEqualityComparer`1" /> implementation to use when comparing elements, or <see langword="null" /> to use the default <see cref="T:System.Collections.Generic.IEqualityComparer`1" /> for the type of an element.
public static
int
LastIndexOf​(ReadOnlySpan<​T> span,
T value)
Searches for the specified value and returns the index of its last occurrence.
Returns The index of the last occurrence of the value in the span. If not found, returns -1.
span
The span to search.
value
The value to search for.
public static
int
LastIndexOf​(ReadOnlySpan<​T> span,
T value,
IEqualityComparer?<​T> comparer = null)
Searches for the specified value and returns the index of its last occurrence. If not found, returns -1.
span
The span to search.
value
The value to search for.
comparer
The <see cref="T:System.Collections.Generic.IEqualityComparer`1" /> implementation to use when comparing elements, or <see langword="null" /> to use the default <see cref="T:System.Collections.Generic.IEqualityComparer`1" /> for the type of an element.
public static
int
LastIndexOf​(Span<​T> span,
ReadOnlySpan<​T> value)
Searches for the specified sequence and returns the index of its last occurrence.
Returns The index of the last occurrence of the value in the span. If not found, returns -1.
span
The span to search.
value
The sequence to search for.
public static
int
LastIndexOf​(Span<​T> span,
T value)
Searches for the specified value and returns the index of its last occurrence.
Returns The index of the last occurrence of the value in the span. If not found, returns -1.
span
The span to search.
value
The value to search for.
public static
int
LastIndexOfAnyInRange​(ReadOnlySpan<​T> span,
T lowInclusive,
T highInclusive)
Searches for the last index of any value in the range between <paramref name="lowInclusive" /> and <paramref name="highInclusive" /> , inclusive.
Returns The index in the span of the last occurrence of any value in the specified range.
If all of the values are outside of the specified range, returns -1.
span
The span to search.
lowInclusive
The lower bound, inclusive, of the range for which to search.
highInclusive
The upper bound, inclusive, of the range for which to search.
public static
int
LastIndexOfAnyInRange​(Span<​T> span,
T lowInclusive,
T highInclusive)
Searches for the last index of any value in the range between <paramref name="lowInclusive" /> and <paramref name="highInclusive" /> , inclusive.
Returns The index in the span of the last occurrence of any value in the specified range.
If all of the values are outside of the specified range, returns -1.
span
The span to search.
lowInclusive
The lower bound, inclusive, of the range for which to search.
highInclusive
The upper bound, inclusive, of the range for which to search.
public static
bool
Overlaps​(ReadOnlySpan<​T> span,
ReadOnlySpan<​T> other)
Determines whether two read-only sequences overlap in memory.
Returns <see langword="true" /> if the two sequences overlap; otherwise, <see langword="false" /> .
span
The first sequence.
other
The second sequence.
public static
bool
Overlaps​(ReadOnlySpan<​T> span,
ReadOnlySpan<​T> other,
Int32& elementOffset)
public static
bool
Overlaps​(Span<​T> span,
ReadOnlySpan<​T> other)
Determines whether a span and a read-only span overlap in memory.
Returns <see langword="true" /> if the two sequences overlap; otherwise, <see langword="false" /> .
span
The span to compare.
other
The read-only span to compare.
public static
bool
Overlaps​(Span<​T> span,
ReadOnlySpan<​T> other,
Int32& elementOffset)
public static
void
Replace​(Span<​T> span,
T oldValue,
T newValue)
Replaces all occurrences of <paramref name="oldValue" /> with <paramref name="newValue" /> .
span
The span in which the elements should be replaced.
oldValue
The value to be replaced with <paramref name="newValue" /> .
newValue
The value to replace all occurrences of <paramref name="oldValue" /> .
public static
void
Replace​(Span<​T> span,
T oldValue,
T newValue,
IEqualityComparer?<​T> comparer = null)
Replaces all occurrences of <paramref name="oldValue" /> with <paramref name="newValue" /> .
span
The span in which the elements should be replaced.
oldValue
The value to be replaced with <paramref name="newValue" /> .
newValue
The value to replace all occurrences of <paramref name="oldValue" /> .
comparer
The <see cref="T:System.Collections.Generic.IEqualityComparer`1" /> implementation to use when comparing elements, or <see langword="null" /> to use the default <see cref="T:System.Collections.Generic.IEqualityComparer`1" /> for the type of an element.
public static
void
Replace​(ReadOnlySpan<​T> source,
Span<​T> destination,
T oldValue,
T newValue)
Copies <paramref name="source" /> to <paramref name="destination" /> , replacing all occurrences of <paramref name="oldValue" /> with <paramref name="newValue" /> .
source
The span to copy.
destination
The span into which the copied and replaced values should be written.
oldValue
The value to be replaced with <paramref name="newValue" /> .
newValue
The value to replace all occurrences of <paramref name="oldValue" /> .
public static
void
Replace​(ReadOnlySpan<​T> source,
Span<​T> destination,
T oldValue,
T newValue,
IEqualityComparer?<​T> comparer = null)
Copies <paramref name="source" /> to <paramref name="destination" /> , replacing all occurrences of <paramref name="oldValue" /> with <paramref name="newValue" /> .
source
The span to copy.
destination
The span into which the copied and replaced values should be written.
oldValue
The value to be replaced with <paramref name="newValue" /> .
newValue
The value to replace all occurrences of <paramref name="oldValue" /> .
comparer
The <see cref="T:System.Collections.Generic.IEqualityComparer`1" /> implementation to use when comparing elements, or <see langword="null" /> to use the default <see cref="T:System.Collections.Generic.IEqualityComparer`1" /> for the type of an element.
public static
void
ReplaceAny​(ReadOnlySpan<​T> source,
Span<​T> destination,
SearchValues<​T> values,
T newValue)
<para>Copies <paramref name="source" /> to <paramref name="destination" />, replacing all occurrences of any of the elements in <paramref name="values" /> with <paramref name="newValue" />.</para>
source
The span to copy.
destination
The span into which the copied and replaced values should be written.
values
The values to be replaced with <paramref name="newValue" /> .
newValue
The value to replace all occurrences of any of the elements in <paramref name="values" /> .
public static
void
ReplaceAny​(Span<​T> span,
SearchValues<​T> values,
T newValue)
<para>Replaces in <paramref name="span" /> all occurrences of any of the elements in <paramref name="values" /> with <paramref name="newValue" />.</para>
span
The span to edit.
values
The values to be replaced with <paramref name="newValue" /> .
newValue
The value to replace all occurrences of any of the elements in <paramref name="values" /> .
public static
void
ReplaceAnyExcept​(ReadOnlySpan<​T> source,
Span<​T> destination,
SearchValues<​T> values,
T newValue)
<para>Copies <paramref name="source" /> to <paramref name="destination" />, replacing all occurrences of any of the elements other than those in <paramref name="values" /> with <paramref name="newValue" />.</para>
source
The span to copy.
destination
The span into which the copied and replaced values should be written.
values
The values to be excluded from replacement with <paramref name="newValue" /> .
newValue
The value to replace all occurrences of any elements other than those in <paramref name="values" /> .
public static
void
ReplaceAnyExcept​(Span<​T> span,
SearchValues<​T> values,
T newValue)
Replaces in <paramref name="span" /> all elements, other than those in <paramref name="values" /> , with <paramref name="newValue" /> .
span
The span to edit.
values
The values to be excluded from replacement with <paramref name="newValue" /> .
newValue
The value to replace all occurrences of any elements other than those in <paramref name="values" /> .
public static
void
Reverse​(Span<​T> span)
Reverses the sequence of the elements in the entire span.
span
The span to reverse.
public static
int
SequenceCompareTo​(ReadOnlySpan<​T> span,
ReadOnlySpan<​T> other)
Determines the relative order of two read-only sequences by comparing their elements using IComparable{T}.CompareTo(T).
Returns A signed integer that indicates the relative order of <paramref name="span" /> and <paramref name="other" /> : <br /> - If less than 0, <paramref name="span" /> precedes than <paramref name="other" /> . <br /> - If 0, <paramref name="span" /> equals <paramref name="other" /> . <br /> - If greater than 0, <paramref name="span" /> follows <paramref name="other" /> .
span
The first sequence to compare.
other
The second sequence to compare.
public static
int
SequenceCompareTo​(ReadOnlySpan<​T> span,
ReadOnlySpan<​T> other,
IComparer?<​T> comparer = null)
Determines the relative order of the sequences being compared by comparing the elements using IComparable{T}.CompareTo(T).
public static
int
SequenceCompareTo​(Span<​T> span,
ReadOnlySpan<​T> other)
Determines the relative order of a span and a read-only span by comparing the elements using IComparable{T}.CompareTo(T).
Returns A signed integer that indicates the relative order of <paramref name="span" /> and <paramref name="other" /> : <br /> - If less than 0, <paramref name="span" /> precedes than <paramref name="other" /> . <br /> - If 0, <paramref name="span" /> equals <paramref name="other" /> . <br /> - If greater than 0, <paramref name="span" /> follows <paramref name="other" /> .
span
The span to compare.
other
The read-only span to compare.
public static
bool
SequenceEqual​(ReadOnlySpan<​T> span,
ReadOnlySpan<​T> other)
Determines whether two read-only sequences are equal by comparing the elements using IEquatable{T}.Equals(T).
Returns <see langword="true" /> if the two sequences are equal; otherwise, <see langword="false" /> .
span
The first sequence to compare.
other
The second sequence to compare.
public static
bool
SequenceEqual​(Span<​T> span,
ReadOnlySpan<​T> other)
Determines whether a span and a read-only span are equal by comparing the elements using IEquatable{T}.Equals(T).
Returns <see langword="true" /> if the two sequences are equal; otherwise, <see langword="false" /> .
span
The span to compare.
other
The read-only span to compare.
public static
bool
SequenceEqual​(ReadOnlySpan<​T> span,
ReadOnlySpan<​T> other,
IEqualityComparer?<​T> comparer = null)
Determines whether two sequences are equal by comparing the elements using an <see cref="T:System.Collections.Generic.IEqualityComparer`1" /> .
Returns <see langword="true" /> if the two sequences are equal; otherwise, <see langword="false" /> .
span
The first sequence to compare.
other
The second sequence to compare.
comparer
The <see cref="T:System.Collections.Generic.IEqualityComparer`1" /> implementation to use when comparing elements, or <see langword="null" /> to use the default <see cref="T:System.Collections.Generic.IEqualityComparer`1" /> for the type of an element.
public static
bool
SequenceEqual​(Span<​T> span,
ReadOnlySpan<​T> other,
IEqualityComparer?<​T> comparer = null)
Determines whether two sequences are equal by comparing the elements using an <see cref="T:System.Collections.Generic.IEqualityComparer`1" /> .
Returns <see langword="true" /> if the two sequences are equal; otherwise, <see langword="false" /> .
span
The first sequence to compare.
other
The second sequence to compare.
comparer
The <see cref="T:System.Collections.Generic.IEqualityComparer`1" /> implementation to use when comparing elements, or <see langword="null" /> to use the default <see cref="T:System.Collections.Generic.IEqualityComparer`1" /> for the type of an element.
public static
void
Sort​(Span<​T> span)
Sorts the elements in the entire <see cref="T:System.Span`1" /> using the <see cref="T:System.IComparable`1" /> implementation of each element of the <see cref="T:System.Span`1" /> .
span
The span of memory to sort.
public static
void
Sort​(Span<​T> span,
Comparison<​T> comparison)
Sorts the elements in the entire <see cref="T:System.Span`1" /> using the specified <see cref="T:System.Comparison`1" /> .
span
The span of memory to sort.
comparison
The method to use when comparing elements.
public static
void
Sort​(Span<​TKey> keys,
Span<​TValue> items)
Sorts a pair of spans (one containing the keys and the other containing the corresponding items) based on the keys in the first <see cref="T:System.Span`1" /> using the <see cref="T:System.IComparable`1" /> implementation of each key.
keys
The span that contains the keys to sort.
items
The span that contains the items that correspond to the keys in <paramref name="keys" /> .
public static
void
Sort​(Span<​TKey> keys,
Span<​TValue> items,
Comparison<​TKey> comparison)
Sorts a pair of spans (one containing the keys and the other containing the corresponding items) based on the keys in the first <see cref="T:System.Span`1" /> using the specified comparison.
keys
The span that contains the keys to sort.
items
The span that contains the items that correspond to the keys in <paramref name="keys" /> .
comparison
The <see cref="T:System.Comparison`1" /> to use when comparing elements.
public static
void
Sort​(Span<​T> span,
TComparer comparer)
Sorts the elements in the entire <see cref="T:System.Span`1" /> using the <typeparamref name="TComparer" /> .
span
The span of memory to sort.
comparer
The method to use when comparing elements, or <see langword="null" /> to use each element's <see cref="T:System.IComparable`1" /> interface implementation.
public static
void
Sort​(Span<​TKey> keys,
Span<​TValue> items,
TComparer comparer)
Sorts a pair of spans (one containing the keys and the other containing the corresponding items) based on the keys in the first <see cref="T:System.Span`1" /> using the specified comparer.
keys
The span that contains the keys to sort.
items
The span that contains the items that correspond to the keys in <paramref name="keys" /> .
comparer
The <see cref="T:System.Collections.Generic.IComparer`1" /> implementation to use when comparing elements, or <see langword="null" /> to use the <see cref="T:System.IComparable`1" /> interface implementation of each element.
public static
SpanSplitEnumerator<​T>
Split​(ReadOnlySpan<​T> source,
T separator)
<para>Returns a type that allows for enumeration of each element within a split span using the provided separator character.</para>
Returns An enumerator that can be used to enumerate each element in a split span using the provided separator character.
source
The source span to be enumerated.
separator
The separator character to be used to split the provided span.
public static
SpanSplitEnumerator<​T>
Split​(ReadOnlySpan<​T> source,
ReadOnlySpan<​T> separator)
<para>Returns a type that allows for enumeration of each element within a split span using the provided separator span.</para>
Returns An enumerator that can be used to enumerate each element in a split span using the provided separator span.
source
The source span to be enumerated.
separator
The separator span to be used to split the provided span.
public static
SpanSplitEnumerator<​T>
SplitAny​(ReadOnlySpan<​T> source,
ReadOnlySpan<​T> separators)
<para>Returns a type that allows for enumeration of each element within a split span using any of the provided elements.</para>
Returns An enumerator that can be used to enumerate each element in a split span using the provided separator characters.
source
The source span to be enumerated.
separators
The separators to be used to split the provided span.
public static
SpanSplitEnumerator<​T>
SplitAny​(ReadOnlySpan<​T> source,
SearchValues<​T> separators)
<para>Returns a type that allows for enumeration of each element within a split span using the provided separator characters.</para>
Returns An enumerator that can be used to enumerate each element in a split span using the provided separator characters.
source
The source span to be enumerated.
separators
The <see cref="T:System.Buffers.SearchValues`1" /> to be used to split the provided span.
public static
int
Split​(ReadOnlySpan<​char> source,
Span<​Range> destination,
char separator,
StringSplitOptions options = 0)
Parses the source <see cref="T:System.ReadOnlySpan`1" /> for the specified <paramref name="separator" /> , populating the <paramref name="destination" /> span with <see cref="T:System.Range" /> instances representing the regions between the separators.
Returns The number of ranges written into <paramref name="destination" /> .
source
The source span to parse.
destination
The destination span into which the resulting ranges are written.
separator
A character that delimits the regions in this instance.
options
A bitwise combination of the enumeration values that specifies whether to trim whitespace and include empty ranges.
public static
int
Split​(ReadOnlySpan<​char> source,
Span<​Range> destination,
ReadOnlySpan<​char> separator,
StringSplitOptions options = 0)
Parses the source <see cref="T:System.ReadOnlySpan`1" /> for the specified <paramref name="separator" /> , populating the <paramref name="destination" /> span with <see cref="T:System.Range" /> instances representing the regions between the separators.
Returns The number of ranges written into <paramref name="destination" /> .
source
The source span to parse.
destination
The destination span into which the resulting ranges are written.
separator
A character that delimits the regions in this instance.
options
A bitwise combination of the enumeration values that specifies whether to trim whitespace and include empty ranges.
public static
int
SplitAny​(ReadOnlySpan<​char> source,
Span<​Range> destination,
ReadOnlySpan<​char> separators,
StringSplitOptions options = 0)
Parses the source <see cref="T:System.ReadOnlySpan`1" /> for one of the specified <paramref name="separators" /> , populating the <paramref name="destination" /> span with <see cref="T:System.Range" /> instances representing the regions between the separators.
Returns The number of ranges written into <paramref name="destination" /> .
source
The source span to parse.
destination
The destination span into which the resulting ranges are written.
separators
Any number of characters that may delimit the regions in this instance. If empty, all Unicode whitespace characters are used as the separators.
options
A bitwise combination of the enumeration values that specifies whether to trim whitespace and include empty ranges.
public static
int
SplitAny​(ReadOnlySpan<​char> source,
Span<​Range> destination,
ReadOnlySpan<​string> separators,
StringSplitOptions options = 0)
Parses the source <see cref="T:System.ReadOnlySpan`1" /> for one of the specified <paramref name="separators" /> , populating the <paramref name="destination" /> span with <see cref="T:System.Range" /> instances representing the regions between the separators.
Returns The number of ranges written into <paramref name="destination" /> .
source
The source span to parse.
destination
The destination span into which the resulting ranges are written.
separators
Any number of strings that may delimit the regions in this instance. If empty, all Unicode whitespace characters are used as the separators.
options
A bitwise combination of the enumeration values that specifies whether to trim whitespace and include empty ranges.
public static
bool
StartsWith​(ReadOnlySpan<​char> span,
ReadOnlySpan<​char> value,
StringComparison comparisonType)
Determines whether a read-only character span begins with a specified value when compared using a specified <see cref="T:System.StringComparison" /> value.
Returns <see langword="true" /> if <paramref name="value" /> matches the beginning of <paramref name="span" /> ; otherwise, <see langword="false" /> .
span
The source span.
value
The sequence to compare to the beginning of the source span.
comparisonType
An enumeration value that determines how <paramref name="span" /> and <paramref name="value" /> are compared.
public static
bool
StartsWith​(ReadOnlySpan<​T> span,
ReadOnlySpan<​T> value)
Determines whether a specified sequence appears at the start of a read-only span.
Returns <see langword="true" /> if <paramref name="value" /> matches the beginning of <paramref name="span" /> ; otherwise, <see langword="false" /> .
span
The read-only character span to search.
value
A sequence to search for at the start of <paramref name="span" /> .
public static
bool
StartsWith​(ReadOnlySpan<​T> span,
ReadOnlySpan<​T> value,
IEqualityComparer?<​T> comparer = null)
Determines whether a specified sequence appears at the start of a read-only span.
span
The source span.
value
The sequence to compare to the start of <paramref name="span" /> .
comparer
The <see cref="T:System.Collections.Generic.IEqualityComparer`1" /> implementation to use when comparing elements, or <see langword="null" /> to use the default <see cref="T:System.Collections.Generic.IEqualityComparer`1" /> for the type of an element.
public static
bool
StartsWith​(Span<​T> span,
ReadOnlySpan<​T> value)
Determines whether a specified sequence appears at the start of a span.
Returns <see langword="true" /> if <paramref name="value" /> matches the beginning of <paramref name="span" /> ; otherwise, <see langword="false" /> .
span
The span to search.
value
A sequence to search for at the start of <paramref name="span" /> .
public static
bool
StartsWith​(ReadOnlySpan<​T> span,
T value)
Determines whether the specified value appears at the start of the span.
Returns <see langword="true" /> if <paramref name="value" /> matches the beginning of <paramref name="span" /> ; otherwise, <see langword="false" /> .
span
The span to search.
value
The value to compare.
public static
bool
StartsWith​(ReadOnlySpan<​T> span,
T value,
IEqualityComparer?<​T> comparer = null)
Determines whether the specified value appears at the start of the span.
Returns <see langword="true" /> if <paramref name="value" /> matches the beginning of <paramref name="span" /> ; otherwise, <see langword="false" /> .
span
The span to search.
value
The value to compare.
comparer
The <see cref="T:System.Collections.Generic.IEqualityComparer`1" /> implementation to use when comparing elements, or <see langword="null" /> to use the default <see cref="T:System.Collections.Generic.IEqualityComparer`1" /> for the type of an element.
public static
int
ToLower​(ReadOnlySpan<​char> source,
Span<​char> destination,
CultureInfo? culture)
Copies the characters from the source span into the destination, converting each character to lowercase, using the casing rules of the specified culture.
Returns The number of characters written into the destination span. If the destination is too small, returns -1.
source
The source span.
destination
The destination span which contains the transformed characters.
culture
An object that supplies culture-specific casing rules.
public static
int
ToLowerInvariant​(ReadOnlySpan<​char> source,
Span<​char> destination)
Copies the characters from the source span into the destination, converting each character to lowercase, using the casing rules of the invariant culture.
Returns The number of characters written into the destination span. If the destination is too small, returns -1.
source
The source span.
destination
The destination span which contains the transformed characters.
public static
int
ToUpper​(ReadOnlySpan<​char> source,
Span<​char> destination,
CultureInfo? culture)
Copies the characters from the source span into the destination, converting each character to uppercase, using the casing rules of the specified culture.
Returns The number of characters written into the destination span. If the destination is too small, returns -1.
source
The source span.
destination
The destination span which contains the transformed characters.
culture
An object that supplies culture-specific casing rules.
public static
int
ToUpperInvariant​(ReadOnlySpan<​char> source,
Span<​char> destination)
Copies the characters from the source span into the destination, converting each character to uppercase using the casing rules of the invariant culture.
Returns The number of characters written into the destination span. If the destination is too small, returns -1.
source
The source span.
destination
The destination span which contains the transformed characters.
public static
Memory<​char>
Trim​(Memory<​char> memory)
Removes all leading and trailing whitespace characters from a character memory region.
Returns The trimmed character memory region.
memory
The source memory from which the characters are removed.
public static
ReadOnlyMemory<​char>
Trim​(ReadOnlyMemory<​char> memory)
Removes all leading and trailing whitespace characters from a read-only character memory region.
Returns The trimmed character memory region.
memory
The source memory from which the characters are removed.
public static
ReadOnlySpan<​char>
Trim​(ReadOnlySpan<​char> span)
Removes all leading and trailing whitespace characters from a read-only character span.
Returns The trimmed read-only character span.
span
The source span from which the characters are removed.
public static
ReadOnlySpan<​char>
Trim​(ReadOnlySpan<​char> span,
char trimChar)
Removes all leading and trailing occurrences of a specified character from a read-only character span.
Returns The trimmed read-only character span.
span
The source span from which the character is removed.
trimChar
The specified character to look for and remove.
public static
ReadOnlySpan<​char>
Trim​(ReadOnlySpan<​char> span,
ReadOnlySpan<​char> trimChars)
Removes all leading and trailing occurrences of a set of characters specified in a read-only span from a read-only character span.
Returns The trimmed read-only character span.
span
The source span from which the characters are removed.
trimChars
The span which contains the set of characters to remove.
public static
Span<​char>
Trim​(Span<​char> span)
Removes all leading and trailing whitespace characters from a character span.
Returns The trimmed character span.
span
The source span from which the characters are removed.
public static
Memory<​char>
TrimEnd​(Memory<​char> memory)
Removes all trailing whitespace characters from a character memory region.
Returns The trimmed character memory region.
memory
The source memory from which the characters are removed.
public static
ReadOnlyMemory<​char>
TrimEnd​(ReadOnlyMemory<​char> memory)
Removes all trailing whitespace characters from a read-only character memory region.
Returns The trimmed read-only character span.
memory
The source memory from which the characters are removed.
public static
ReadOnlySpan<​char>
TrimEnd​(ReadOnlySpan<​char> span)
Removes all trailing whitespace characters from a read-only character span.
Returns The trimmed read-only character span.
span
The source span from which the characters are removed.
public static
ReadOnlySpan<​char>
TrimEnd​(ReadOnlySpan<​char> span,
char trimChar)
Removes all trailing occurrences of a specified character from a read-only span.
Returns The trimmed read-only character span.
span
The source span from which the character is removed.
trimChar
The specified character to look for and remove.
public static
ReadOnlySpan<​char>
TrimEnd​(ReadOnlySpan<​char> span,
ReadOnlySpan<​char> trimChars)
Removes all trailing occurrences of a set of characters specified in a read-only span from a read-only character span.
Returns The trimmed read-only character span.
span
The source span from which the characters are removed.
trimChars
The span which contains the set of characters to remove.
public static
Span<​char>
TrimEnd​(Span<​char> span)
Removes all trailing whitespace characters from a character span.
Returns The trimmed character span.
span
The source span from which the characters are removed.
public static
Memory<​T>
TrimEnd​(Memory<​T> memory,
ReadOnlySpan<​T> trimElements)
Removes all trailing occurrences of a set of elements specified in a read-only span from a memory region.
Returns The trimmed memory region.
memory
The source memory from which the elements are removed.
trimElements
The span which contains the set of elements to remove.
public static
Memory<​T>
TrimEnd​(Memory<​T> memory,
T trimElement)
Removes all trailing occurrences of a specified element from a character memory region.
Returns The trimmed memory region.
memory
The source memory from which the element is removed.
trimElement
The specified element to look for and remove.
public static
ReadOnlyMemory<​T>
TrimEnd​(ReadOnlyMemory<​T> memory,
ReadOnlySpan<​T> trimElements)
Removes all trailing occurrences of a set of elements specified in a read-only span from a read-only memory region.
Returns The trimmed read-only memory region.
memory
The source memory from which the elements are removed.
trimElements
The span which contains the set of elements to remove.
public static
ReadOnlyMemory<​T>
TrimEnd​(ReadOnlyMemory<​T> memory,
T trimElement)
Removes all trailing occurrences of a specified element from a read-only memory region.
Returns The trimmed read-only memory region.
memory
The source memory from which the element is removed.
trimElement
The specified element to look for and remove.
public static
ReadOnlySpan<​T>
TrimEnd​(ReadOnlySpan<​T> span,
ReadOnlySpan<​T> trimElements)
Removes all trailing occurrences of a set of elements specified in a read-only span from a read-only span.
Returns The trimmed read-only span.
span
The source span from which the elements are removed.
trimElements
The span which contains the set of elements to remove.
public static
ReadOnlySpan<​T>
TrimEnd​(ReadOnlySpan<​T> span,
T trimElement)
Removes all trailing occurrences of a specified element from a read-only span.
Returns The trimmed read-only span.
span
The source span from which the element is removed.
trimElement
The specified element to look for and remove.
public static
Span<​T>
TrimEnd​(Span<​T> span,
ReadOnlySpan<​T> trimElements)
Removes all trailing occurrences of a set of elements specified in a read-only span from a span.
Returns The trimmed span.
span
The source span from which the elements are removed.
trimElements
The span which contains the set of elements to remove.
public static
Span<​T>
TrimEnd​(Span<​T> span,
T trimElement)
Removes all trailing occurrences of a specified element from a span.
Returns The trimmed span.
span
The source span from which the element is removed.
trimElement
The specified element to look for and remove.
public static
Memory<​char>
TrimStart​(Memory<​char> memory)
Removes all leading whitespace characters from a memory region.
Returns The trimmed character memory region.
memory
The source memory from which the characters are removed.
public static
ReadOnlyMemory<​char>
TrimStart​(ReadOnlyMemory<​char> memory)
Removes all leading whitespace characters from a read-only memory region.
Returns The trimmed read-only character memory region.
memory
The source memory from which the characters are removed.
public static
ReadOnlySpan<​char>
TrimStart​(ReadOnlySpan<​char> span)
Removes all leading whitespace characters from a read-only span.
Returns The trimmed read-only character span.
span
The source span from which the characters are removed.
public static
ReadOnlySpan<​char>
TrimStart​(ReadOnlySpan<​char> span,
char trimChar)
Removes all leading occurrences of a specified character from the span.
Returns The trimmed read-only character span.
span
The source span from which the character is removed.
trimChar
The specified character to look for and remove.
public static
ReadOnlySpan<​char>
TrimStart​(ReadOnlySpan<​char> span,
ReadOnlySpan<​char> trimChars)
Removes all leading occurrences of a set of characters specified in a read-only span from the span.
Returns The trimmed read-only character span.
span
The source span from which the characters are removed.
trimChars
The span which contains the set of characters to remove.
public static
Span<​char>
TrimStart​(Span<​char> span)
Removes all leading whitespace characters from a span.
Returns The trimmed character span.
span
The source span from which the characters are removed.
public static
Memory<​T>
TrimStart​(Memory<​T> memory,
ReadOnlySpan<​T> trimElements)
Removes all leading occurrences of a set of elements specified in a read-only span from a memory region.
Returns The trimmed memory region.
memory
The source memory from which the elements are removed.
trimElements
The span which contains the set of elements to remove.
public static
Memory<​T>
TrimStart​(Memory<​T> memory,
T trimElement)
Removes all leading occurrences of a specified element from a memory region.
Returns The trimmed memory region.
memory
The source memory region from which the element is removed.
trimElement
The specified element to look for and remove.
public static
ReadOnlyMemory<​T>
TrimStart​(ReadOnlyMemory<​T> memory,
ReadOnlySpan<​T> trimElements)
Removes all leading occurrences of a set of elements specified in a read-only span from a memory region.
Returns The trimmed read-only memory region.
memory
The source memory from which the elements are removed.
trimElements
The span which contains the set of elements to remove.
public static
ReadOnlyMemory<​T>
TrimStart​(ReadOnlyMemory<​T> memory,
T trimElement)
Removes all leading occurrences of a specified element from a memory region.
Returns The trimmed read-only memory region.
memory
The source memory from which the element is removed.
trimElement
The specified element to look for and remove.
public static
ReadOnlySpan<​T>
TrimStart​(ReadOnlySpan<​T> span,
ReadOnlySpan<​T> trimElements)
Removes all leading occurrences of a set of elements specified in a read-only span from the span.
Returns The trimmed read-only span.
span
The source span from which the elements are removed.
trimElements
The span which contains the set of elements to remove.
public static
ReadOnlySpan<​T>
TrimStart​(ReadOnlySpan<​T> span,
T trimElement)
Removes all leading occurrences of a specified element from the span.
Returns The trimmed read-only span.
span
The source span from which the element is removed.
trimElement
The specified element to look for and remove.
public static
Span<​T>
TrimStart​(Span<​T> span,
ReadOnlySpan<​T> trimElements)
Removes all leading occurrences of a set of elements specified in a read-only span from the span.
Returns The trimmed span.
span
The source span from which the elements are removed.
trimElements
The span which contains the set of elements to remove.
public static
Span<​T>
TrimStart​(Span<​T> span,
T trimElement)
Removes all leading occurrences of a specified element from the span.
Returns The trimmed span.
span
The source span from which the element is removed.
trimElement
The specified element to look for and remove.
public static
Memory<​T>
Trim​(Memory<​T> memory,
ReadOnlySpan<​T> trimElements)
Removes all leading and trailing occurrences of a set of elements specified in a read-only span from a memory region.
Returns The trimmed memory region.
memory
The source memory from which the elements are removed.
trimElements
The span which contains the set of elements to remove.
public static
Memory<​T>
Trim​(Memory<​T> memory,
T trimElement)
Removes all leading and trailing occurrences of a specified element from a memory region.
Returns The trimmed memory region.
memory
The source memory from which the element is removed.
trimElement
The specified element to look for and remove.
public static
ReadOnlyMemory<​T>
Trim​(ReadOnlyMemory<​T> memory,
ReadOnlySpan<​T> trimElements)
Removes all leading and trailing occurrences of a set of elements specified in a read-only span from a read-only memory region.
Returns The trimmed read-only memory region.
memory
The source memory from which the elements are removed.
trimElements
The span which contains the set of elements to remove.
public static
ReadOnlyMemory<​T>
Trim​(ReadOnlyMemory<​T> memory,
T trimElement)
Removes all leading and trailing occurrences of a specified element from a read-only memory region.
Returns The trimmed read-only memory region.
memory
The source memory from which the element is removed.
trimElement
The specified element to look for and remove.
public static
ReadOnlySpan<​T>
Trim​(ReadOnlySpan<​T> span,
ReadOnlySpan<​T> trimElements)
Removes all leading and trailing occurrences of a set of elements specified in a read-only span from a read-only span.
Returns The trimmed read-only span.
span
The source span from which the elements are removed.
trimElements
The span which contains the set of elements to remove.
public static
ReadOnlySpan<​T>
Trim​(ReadOnlySpan<​T> span,
T trimElement)
Removes all leading and trailing occurrences of a specified element from a read-only span.
Returns The trimmed read-only span.
span
The source span from which the element is removed.
trimElement
The specified element to look for and remove.
public static
Span<​T>
Trim​(Span<​T> span,
ReadOnlySpan<​T> trimElements)
Removes all leading and trailing occurrences of a set of elements specified in a read-only span from a span.
Returns The trimmed span.
span
The source span from which the elements are removed.
trimElements
The span which contains the set of elements to remove.
public static
Span<​T>
Trim​(Span<​T> span,
T trimElement)
Removes all leading and trailing occurrences of a specified element from a span.
Returns The trimmed span.
span
The source span from which the element is removed.
trimElement
The specified element to look for and remove.
public static
bool
TryWrite​(Span<​char> destination,
TryWriteInterpolatedStringHandler& handler,
Int32& charsWritten)
public static
bool
TryWrite​(Span<​char> destination,
IFormatProvider? provider,
TryWriteInterpolatedStringHandler& handler,
Int32& charsWritten)
public static
bool
TryWrite​(Span<​char> destination,
IFormatProvider? provider,
CompositeFormat format,
Int32& charsWritten,
TArg0 arg0)
public static
bool
TryWrite​(Span<​char> destination,
IFormatProvider? provider,
CompositeFormat format,
Int32& charsWritten,
TArg0 arg0,
TArg1 arg1)
public static
bool
TryWrite​(Span<​char> destination,
IFormatProvider? provider,
CompositeFormat format,
Int32& charsWritten,
TArg0 arg0,
TArg1 arg1,
TArg2 arg2)
public static
bool
TryWrite​(Span<​char> destination,
IFormatProvider? provider,
CompositeFormat format,
Int32& charsWritten,
object[] args)
public static
bool
TryWrite​(Span<​char> destination,
IFormatProvider? provider,
CompositeFormat format,
Int32& charsWritten,
ReadOnlySpan<​object> args)
public
bool
Equals​(object obj)
Inherited from object
protected
void
Finalize​()
Inherited from object
public
int
GetHashCode​()
Inherited from object
protected
object
MemberwiseClone​()
Inherited from object
public
string
ToString​()
Inherited from object