<PackageReference Include="System.Memory" Version="4.6.0" />

MemoryExtensions

public static class MemoryExtensions
Extension methods for Span{T}, Memory{T}, and friends.
public static Memory<T> AsMemory<T>(this T[] array)

Creates a new memory over the target array.

public static Memory<T> AsMemory<T>(this T[] array, int start)

Creates a new memory over the portion of the target array beginning at 'start' index and ending at 'end' index (exclusive).

public static Memory<T> AsMemory<T>(this T[] array, int start, int length)

Creates a new memory over the portion of the target array beginning at 'start' index and ending at 'end' index (exclusive).

public static Memory<T> AsMemory<T>(this ArraySegment<T> segment)

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

public static Memory<T> AsMemory<T>(this ArraySegment<T> segment, int start)

Creates a new memory over the portion of the target array beginning at 'start' index and ending at 'end' index (exclusive).

public static Memory<T> AsMemory<T>(this ArraySegment<T> segment, int start, int length)

Creates a new memory over the portion of the target array beginning at 'start' index and ending at 'end' index (exclusive).

public static ReadOnlyMemory<char> AsMemory(this string text)

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

public static ReadOnlyMemory<char> AsMemory(this string text, int start)

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

public static ReadOnlyMemory<char> AsMemory(this string text, int start, int length)

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

public static Span<T> AsSpan<T>(this T[] array)

Creates a new span over the target array.

public static Span<T> AsSpan<T>(this T[] array, int start, int length)

Creates a new Span over the portion of the target array beginning at 'start' index and ending at 'end' index (exclusive).

public static Span<T> AsSpan<T>(this ArraySegment<T> segment)

Creates a new span over the portion of the target array segment.

public static Span<T> AsSpan<T>(this ArraySegment<T> segment, int start)

Creates a new Span over the portion of the target array beginning at 'start' index and ending at 'end' index (exclusive).

public static Span<T> AsSpan<T>(this ArraySegment<T> segment, int start, int length)

Creates a new Span over the portion of the target array beginning at 'start' index and ending at 'end' index (exclusive).

public static Span<T> AsSpan<T>(this T[] array, int start)

Creates a new span over the portion of the target array.

public static ReadOnlySpan<char> AsSpan(this string text)

Creates a new readonly span over the portion of the target string.

public static ReadOnlySpan<char> AsSpan(this string text, int start)

Creates a new readonly span over the portion of the target string.

public static ReadOnlySpan<char> AsSpan(this string text, int start, int length)

Creates a new readonly span over the portion of the target string.

public static int BinarySearch<T>(this Span<T> span, IComparable<T> comparable)

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

public static int BinarySearch<T, TComparable>(this Span<T> span, TComparable comparable) where TComparable : IComparable<T>

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

public static int BinarySearch<T, TComparer>(this Span<T> span, T value, TComparer comparer) where TComparer : IComparer<T>

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

public static int BinarySearch<T>(this ReadOnlySpan<T> span, IComparable<T> comparable)

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

public static int BinarySearch<T, TComparable>(this ReadOnlySpan<T> span, TComparable comparable) where TComparable : IComparable<T>

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

public static int BinarySearch<T, TComparer>(this ReadOnlySpan<T> span, T value, TComparer comparer) where TComparer : IComparer<T>

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

public static int CompareTo(this ReadOnlySpan<char> span, ReadOnlySpan<char> other, StringComparison comparisonType)

Compares the specified span and other using the specified comparisonType, and returns an integer that indicates their relative position in the sort order. The source span.The value to compare with the source span.One of the enumeration values that determines how the span and other are compared.

public static bool Contains(this ReadOnlySpan<char> span, ReadOnlySpan<char> value, StringComparison comparisonType)

Returns a value indicating whether the specified value occurs within the span. The source span.The value to seek within the source span.One of the enumeration values that determines how the span and value are compared.

public static void CopyTo<T>(this T[] source, Span<T> destination)

Copies the contents of the array into the span. If the source and destinations overlap, this method behaves as if the original values in a temporary location before the destination is overwritten. The array to copy items from.The span to copy items into.Thrown when the destination Span is shorter than the source array.

public static void CopyTo<T>(this T[] source, Memory<T> destination)

Copies the contents of the array into the memory. If the source and destinations overlap, this method behaves as if the original values are in a temporary location before the destination is overwritten. The array to copy items from.The memory to copy items into.Thrown when the destination is shorter than the source array.

public static bool EndsWith<T>(this Span<T> span, ReadOnlySpan<T> value) where T : IEquatable<T>

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

public static bool EndsWith<T>(this ReadOnlySpan<T> span, ReadOnlySpan<T> value) where T : IEquatable<T>

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

public static bool EndsWith(this ReadOnlySpan<char> span, ReadOnlySpan<char> value, StringComparison comparisonType)

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

public static bool Equals(this ReadOnlySpan<char> span, ReadOnlySpan<char> other, StringComparison comparisonType)

Determines whether this span and the specified other span have the same characters when compared using the specified comparisonType option. The source span.The value to compare with the source span.One of the enumeration values that determines how the span and other are compared.

public static int IndexOf<T>(this Span<T> span, T value) where T : IEquatable<T>

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

public static int IndexOf<T>(this Span<T> span, ReadOnlySpan<T> value) where T : IEquatable<T>

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

public static int IndexOf<T>(this ReadOnlySpan<T> span, T value) where T : IEquatable<T>

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

public static int IndexOf<T>(this ReadOnlySpan<T> span, ReadOnlySpan<T> value) where T : IEquatable<T>

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

public static int IndexOf(this ReadOnlySpan<char> span, ReadOnlySpan<char> value, StringComparison comparisonType)

Reports the zero-based index of the first occurrence of the specified value in the current span. The source span.The value to seek within the source span.One of the enumeration values that determines how the span and value are compared.

public static int IndexOfAny<T>(this Span<T> span, T value0, T value1) where T : IEquatable<T>

Searches for the first index of any of the specified values similar to calling IndexOf several times with the logical OR operator. If not found, returns -1.

public static int IndexOfAny<T>(this Span<T> span, T value0, T value1, T value2) where T : IEquatable<T>

Searches for the first index of any of the specified values similar to calling IndexOf several times with the logical OR operator. If not found, returns -1.

public static int IndexOfAny<T>(this Span<T> span, ReadOnlySpan<T> values) where T : IEquatable<T>

Searches for the first index of any of the specified values similar to calling IndexOf several times with the logical OR operator. If not found, returns -1.

public static int IndexOfAny<T>(this ReadOnlySpan<T> span, T value0, T value1) where T : IEquatable<T>

Searches for the first index of any of the specified values similar to calling IndexOf several times with the logical OR operator. If not found, returns -1.

public static int IndexOfAny<T>(this ReadOnlySpan<T> span, T value0, T value1, T value2) where T : IEquatable<T>

Searches for the first index of any of the specified values similar to calling IndexOf several times with the logical OR operator. If not found, returns -1.

public static int IndexOfAny<T>(this ReadOnlySpan<T> span, ReadOnlySpan<T> values) where T : IEquatable<T>

Searches for the first index of any of the specified values similar to calling IndexOf several times with the logical OR operator. If not found, returns -1.

public static bool IsWhiteSpace(this ReadOnlySpan<char> span)

Indicates whether the specified span contains only white-space characters.

public static int LastIndexOf<T>(this Span<T> span, T value) where T : IEquatable<T>

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

public static int LastIndexOf<T>(this Span<T> span, ReadOnlySpan<T> value) where T : IEquatable<T>

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

public static int LastIndexOf<T>(this ReadOnlySpan<T> span, T value) where T : IEquatable<T>

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

public static int LastIndexOf<T>(this ReadOnlySpan<T> span, ReadOnlySpan<T> value) where T : IEquatable<T>

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

public static int LastIndexOfAny<T>(this Span<T> span, T value0, T value1) where T : IEquatable<T>

Searches for the last index of any of the specified values similar to calling LastIndexOf several times with the logical OR operator. If not found, returns -1.

public static int LastIndexOfAny<T>(this Span<T> span, T value0, T value1, T value2) where T : IEquatable<T>

Searches for the last index of any of the specified values similar to calling LastIndexOf several times with the logical OR operator. If not found, returns -1.

public static int LastIndexOfAny<T>(this Span<T> span, ReadOnlySpan<T> values) where T : IEquatable<T>

Searches for the last index of any of the specified values similar to calling LastIndexOf several times with the logical OR operator. If not found, returns -1.

public static int LastIndexOfAny<T>(this ReadOnlySpan<T> span, T value0, T value1) where T : IEquatable<T>

Searches for the last index of any of the specified values similar to calling LastIndexOf several times with the logical OR operator. If not found, returns -1.

public static int LastIndexOfAny<T>(this ReadOnlySpan<T> span, T value0, T value1, T value2) where T : IEquatable<T>

Searches for the last index of any of the specified values similar to calling LastIndexOf several times with the logical OR operator. If not found, returns -1.

public static int LastIndexOfAny<T>(this ReadOnlySpan<T> span, ReadOnlySpan<T> values) where T : IEquatable<T>

Searches for the last index of any of the specified values similar to calling LastIndexOf several times with the logical OR operator. If not found, returns -1.

public static bool Overlaps<T>(this Span<T> span, ReadOnlySpan<T> other)

Determines whether two sequences overlap in memory.

public static bool Overlaps<T>(this Span<T> span, ReadOnlySpan<T> other, out int elementOffset)

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

public static bool Overlaps<T>(this ReadOnlySpan<T> span, ReadOnlySpan<T> other)

Determines whether two sequences overlap in memory.

public static bool Overlaps<T>(this ReadOnlySpan<T> span, ReadOnlySpan<T> other, out int elementOffset)

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

public static void Reverse<T>(this Span<T> span)

Reverses the sequence of the elements in the entire span.

public static int SequenceCompareTo<T>(this Span<T> span, ReadOnlySpan<T> other) where T : IComparable<T>

Determines the relative order of the sequences being compared by comparing the elements using IComparable{T}.CompareTo(T).

public static int SequenceCompareTo<T>(this ReadOnlySpan<T> span, ReadOnlySpan<T> other) where T : IComparable<T>

Determines the relative order of the sequences being compared by comparing the elements using IComparable{T}.CompareTo(T).

public static bool SequenceEqual<T>(this Span<T> span, ReadOnlySpan<T> other) where T : IEquatable<T>

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

public static bool SequenceEqual<T>(this ReadOnlySpan<T> span, ReadOnlySpan<T> other) where T : IEquatable<T>

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

public static bool StartsWith<T>(this Span<T> span, ReadOnlySpan<T> value) where T : IEquatable<T>

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

public static bool StartsWith<T>(this ReadOnlySpan<T> span, ReadOnlySpan<T> value) where T : IEquatable<T>

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

public static bool StartsWith(this ReadOnlySpan<char> span, ReadOnlySpan<char> value, StringComparison comparisonType)

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

public static int ToLower(this 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.

public static int ToLowerInvariant(this 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.

public static int ToUpper(this 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.

public static int ToUpperInvariant(this 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.

public static ReadOnlySpan<char> Trim(this ReadOnlySpan<char> span)

Removes all leading and trailing white-space characters from the span.

public static ReadOnlySpan<char> Trim(this ReadOnlySpan<char> span, char trimChar)

Removes all leading and trailing occurrences of a specified character.

public static ReadOnlySpan<char> Trim(this ReadOnlySpan<char> span, ReadOnlySpan<char> trimChars)

Removes all leading and trailing occurrences of a set of characters specified in a readonly span from the span.

public static ReadOnlySpan<char> TrimEnd(this ReadOnlySpan<char> span)

Removes all trailing white-space characters from the span.

public static ReadOnlySpan<char> TrimEnd(this ReadOnlySpan<char> span, char trimChar)

Removes all trailing occurrences of a specified character.

public static ReadOnlySpan<char> TrimEnd(this ReadOnlySpan<char> span, ReadOnlySpan<char> trimChars)

Removes all trailing occurrences of a set of characters specified in a readonly span from the span.

public static ReadOnlySpan<char> TrimStart(this ReadOnlySpan<char> span)

Removes all leading white-space characters from the span.

public static ReadOnlySpan<char> TrimStart(this ReadOnlySpan<char> span, char trimChar)

Removes all leading occurrences of a specified character.

public static ReadOnlySpan<char> TrimStart(this ReadOnlySpan<char> span, ReadOnlySpan<char> trimChars)

Removes all leading occurrences of a set of characters specified in a readonly span from the span.