MemoryExtensions.TrimEnd Method

Definition

Overloads

TrimEnd(ReadOnlySpan<Char>, Char)

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

TrimEnd(Memory<Char>)

Removes all trailing whitespace characters from a character memory region.

TrimEnd(ReadOnlyMemory<Char>)

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

TrimEnd(ReadOnlySpan<Char>)

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

TrimEnd(Span<Char>)

Removes all trailing whitespace characters from a character span.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

TrimEnd(ReadOnlySpan<Char>, Char)

Source:
MemoryExtensions.Trim.cs
Source:
MemoryExtensions.Trim.cs
Source:
MemoryExtensions.Trim.cs

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

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

Parameters

span
ReadOnlySpan<Char>

The source span from which the character is removed.

trimChar
Char

The specified character to look for and remove.

Returns

The trimmed read-only character span.

Applies to

.NET 9 and other versions
Product Versions
.NET Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 4.7 (package-provided), 4.7.1 (package-provided), 4.7.2 (package-provided), 4.8 (package-provided)
.NET Standard 2.0 (package-provided), 2.1

TrimEnd(Memory<Char>)

Source:
MemoryExtensions.Trim.cs
Source:
MemoryExtensions.Trim.cs
Source:
MemoryExtensions.Trim.cs

Removes all trailing whitespace characters from a character memory region.

C#
public static Memory<char> TrimEnd(this Memory<char> memory);

Parameters

memory
Memory<Char>

The source memory from which the characters are removed.

Returns

The trimmed character memory region.

Applies to

.NET 9 and other versions
Product Versions
.NET Core 3.0, Core 3.1, 5, 6, 7, 8, 9

TrimEnd(ReadOnlyMemory<Char>)

Source:
MemoryExtensions.Trim.cs
Source:
MemoryExtensions.Trim.cs
Source:
MemoryExtensions.Trim.cs

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

C#
public static ReadOnlyMemory<char> TrimEnd(this ReadOnlyMemory<char> memory);

Parameters

memory
ReadOnlyMemory<Char>

The source memory from which the characters are removed.

Returns

The trimmed read-only character span.

Applies to

.NET 9 and other versions
Product Versions
.NET Core 3.0, Core 3.1, 5, 6, 7, 8, 9

TrimEnd(ReadOnlySpan<Char>)

Source:
MemoryExtensions.Trim.cs
Source:
MemoryExtensions.Trim.cs
Source:
MemoryExtensions.Trim.cs

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

C#
public static ReadOnlySpan<char> TrimEnd(this ReadOnlySpan<char> span);

Parameters

span
ReadOnlySpan<Char>

The source span from which the characters are removed.

Returns

The trimmed read-only character span.

Applies to

.NET 9 and other versions
Product Versions
.NET Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 4.7 (package-provided), 4.7.1 (package-provided), 4.7.2 (package-provided), 4.8 (package-provided)
.NET Standard 2.0 (package-provided), 2.1

TrimEnd(Span<Char>)

Source:
MemoryExtensions.Trim.cs
Source:
MemoryExtensions.Trim.cs
Source:
MemoryExtensions.Trim.cs

Removes all trailing whitespace characters from a character span.

C#
public static Span<char> TrimEnd(this Span<char> span);

Parameters

span
Span<Char>

The source span from which the characters are removed.

Returns

The trimmed character span.

Applies to

.NET 9 and other versions
Product Versions
.NET Core 3.0, Core 3.1, 5, 6, 7, 8, 9

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

Source:
MemoryExtensions.Trim.cs
Source:
MemoryExtensions.Trim.cs
Source:
MemoryExtensions.Trim.cs

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

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

Parameters

span
ReadOnlySpan<Char>

The source span from which the characters are removed.

trimChars
ReadOnlySpan<Char>

The span which contains the set of characters to remove.

Returns

The trimmed read-only character span.

Remarks

If trimChars is empty, whitespace characters are removed instead.

Applies to

.NET 9 and other versions
Product Versions
.NET Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 4.7 (package-provided), 4.7.1 (package-provided), 4.7.2 (package-provided), 4.8 (package-provided)
.NET Standard 2.0 (package-provided), 2.1

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

Source:
MemoryExtensions.Trim.cs
Source:
MemoryExtensions.Trim.cs
Source:
MemoryExtensions.Trim.cs

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

C#
public static Memory<T> TrimEnd<T>(this Memory<T> memory, T trimElement) where T : IEquatable<T>;

Type Parameters

T

The type of the elements in the memory region.

Parameters

memory
Memory<T>

The source memory from which the element is removed.

trimElement
T

The specified element to look for and remove.

Returns

The trimmed memory region.

Applies to

.NET 9 and other versions
Product Versions
.NET Core 3.0, Core 3.1, 5, 6, 7, 8, 9

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

Source:
MemoryExtensions.Trim.cs
Source:
MemoryExtensions.Trim.cs
Source:
MemoryExtensions.Trim.cs

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

C#
public static Span<T> TrimEnd<T>(this Span<T> span, ReadOnlySpan<T> trimElements) where T : IEquatable<T>;

Type Parameters

T

The type of the elements in the span.

Parameters

span
Span<T>

The source span from which the elements are removed.

trimElements
ReadOnlySpan<T>

The span which contains the set of elements to remove.

Returns

The trimmed span.

Remarks

If trimElements is empty, the span is returned unaltered.

Applies to

.NET 9 and other versions
Product Versions
.NET Core 3.0, Core 3.1, 5, 6, 7, 8, 9

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

Source:
MemoryExtensions.Trim.cs
Source:
MemoryExtensions.Trim.cs
Source:
MemoryExtensions.Trim.cs

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

C#
public static Span<T> TrimEnd<T>(this Span<T> span, T trimElement) where T : IEquatable<T>;

Type Parameters

T

The type of the elements in the span.

Parameters

span
Span<T>

The source span from which the element is removed.

trimElement
T

The specified element to look for and remove.

Returns

The trimmed span.

Applies to

.NET 9 and other versions
Product Versions
.NET Core 3.0, Core 3.1, 5, 6, 7, 8, 9

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

Source:
MemoryExtensions.Trim.cs
Source:
MemoryExtensions.Trim.cs
Source:
MemoryExtensions.Trim.cs

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

C#
public static ReadOnlySpan<T> TrimEnd<T>(this ReadOnlySpan<T> span, T trimElement) where T : IEquatable<T>;

Type Parameters

T

The type of the elements in the read-only span.

Parameters

span
ReadOnlySpan<T>

The source span from which the element is removed.

trimElement
T

The specified element to look for and remove.

Returns

The trimmed read-only span.

Applies to

.NET 9 and other versions
Product Versions
.NET Core 3.0, Core 3.1, 5, 6, 7, 8, 9

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

Source:
MemoryExtensions.Trim.cs
Source:
MemoryExtensions.Trim.cs
Source:
MemoryExtensions.Trim.cs

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

C#
public static Memory<T> TrimEnd<T>(this Memory<T> memory, ReadOnlySpan<T> trimElements) where T : IEquatable<T>;

Type Parameters

T

The type of the elements in the memory region.

Parameters

memory
Memory<T>

The source memory from which the elements are removed.

trimElements
ReadOnlySpan<T>

The span which contains the set of elements to remove.

Returns

The trimmed memory region.

Remarks

If trimElements is empty, the memory is returned unaltered.

Applies to

.NET 9 and other versions
Product Versions
.NET Core 3.0, Core 3.1, 5, 6, 7, 8, 9

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

Source:
MemoryExtensions.Trim.cs
Source:
MemoryExtensions.Trim.cs
Source:
MemoryExtensions.Trim.cs

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

C#
public static ReadOnlyMemory<T> TrimEnd<T>(this ReadOnlyMemory<T> memory, T trimElement) where T : IEquatable<T>;

Type Parameters

T

The type of the elements in the read-only memory region.

Parameters

memory
ReadOnlyMemory<T>

The source memory from which the element is removed.

trimElement
T

The specified element to look for and remove.

Returns

The trimmed read-only memory region.

Applies to

.NET 9 and other versions
Product Versions
.NET Core 3.0, Core 3.1, 5, 6, 7, 8, 9

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

Source:
MemoryExtensions.Trim.cs
Source:
MemoryExtensions.Trim.cs
Source:
MemoryExtensions.Trim.cs

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

C#
public static ReadOnlyMemory<T> TrimEnd<T>(this ReadOnlyMemory<T> memory, ReadOnlySpan<T> trimElements) where T : IEquatable<T>;

Type Parameters

T

The type of the elements in the read-only memory region.

Parameters

memory
ReadOnlyMemory<T>

The source memory from which the elements are removed.

trimElements
ReadOnlySpan<T>

The span which contains the set of elements to remove.

Returns

The trimmed read-only memory region.

Remarks

If trimElements is empty, the memory is returned unaltered.

Applies to

.NET 9 and other versions
Product Versions
.NET Core 3.0, Core 3.1, 5, 6, 7, 8, 9

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

Source:
MemoryExtensions.Trim.cs
Source:
MemoryExtensions.Trim.cs
Source:
MemoryExtensions.Trim.cs

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

C#
public static ReadOnlySpan<T> TrimEnd<T>(this ReadOnlySpan<T> span, ReadOnlySpan<T> trimElements) where T : IEquatable<T>;

Type Parameters

T

The type of the elements in the read-only span.

Parameters

span
ReadOnlySpan<T>

The source span from which the elements are removed.

trimElements
ReadOnlySpan<T>

The span which contains the set of elements to remove.

Returns

The trimmed read-only span.

Remarks

If trimElements is empty, the span is returned unaltered.

Applies to

.NET 9 and other versions
Product Versions
.NET Core 3.0, Core 3.1, 5, 6, 7, 8, 9