MemoryExtensions.Trim Method (System) (original) (raw)

Definition

Namespace:

System

Assemblies:

netstandard.dll, System.Memory.dll

Assembly:

System.Memory.dll

Assembly:

netstandard.dll

Package:

System.Memory v4.6.3

Important

Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.

Overloads

Trim(ReadOnlySpan, ReadOnlySpan) Removes all leading and trailing occurrences of a set of characters specified in a read-only span from a read-only character span.
Trim(ReadOnlySpan, Char) Removes all leading and trailing occurrences of a specified character from a read-only character span.
Trim(Span) Removes all leading and trailing whitespace characters from a character span.
Trim(Memory) Removes all leading and trailing whitespace characters from a character memory region.
Trim(ReadOnlyMemory) Removes all leading and trailing whitespace characters from a read-only character memory region.
Trim(ReadOnlySpan) Removes all leading and trailing whitespace characters from a read-only character span.
Trim(Memory, ReadOnlySpan) Removes all leading and trailing occurrences of a set of elements specified in a read-only span from a memory region.
Trim(Memory, T) Removes all leading and trailing occurrences of a specified element from a memory region.
Trim(ReadOnlyMemory, ReadOnlySpan) Removes all leading and trailing occurrences of a set of elements specified in a read-only span from a read-only memory region.
Trim(ReadOnlyMemory, T) Removes all leading and trailing occurrences of a specified element from a read-only memory region.
Trim(ReadOnlySpan, ReadOnlySpan) Removes all leading and trailing occurrences of a set of elements specified in a read-only span from a read-only span.
Trim(ReadOnlySpan, T) Removes all leading and trailing occurrences of a specified element from a read-only span.
Trim(Span, ReadOnlySpan) Removes all leading and trailing occurrences of a set of elements specified in a read-only span from a span.
Trim(Span, T) Removes all leading and trailing occurrences of a specified element from a span.

Trim(ReadOnlySpan, ReadOnlySpan)

Source:

MemoryExtensions.Trim.cs

Source:

MemoryExtensions.Trim.cs

Source:

MemoryExtensions.Trim.cs

Source:

MemoryExtensions.Trim.cs

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

public:
[System::Runtime::CompilerServices::Extension]
 static ReadOnlySpan<char> Trim(ReadOnlySpan<char> span, ReadOnlySpan<char> trimChars);
public static ReadOnlySpan<char> Trim(this ReadOnlySpan<char> span, ReadOnlySpan<char> trimChars);
static member Trim : ReadOnlySpan<char> * ReadOnlySpan<char> -> ReadOnlySpan<char>
<Extension()>
Public Function Trim (span As ReadOnlySpan(Of Char), trimChars As ReadOnlySpan(Of Char)) As ReadOnlySpan(Of Char)

Parameters

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

Trim(ReadOnlySpan, Char)

Source:

MemoryExtensions.Trim.cs

Source:

MemoryExtensions.Trim.cs

Source:

MemoryExtensions.Trim.cs

Source:

MemoryExtensions.Trim.cs

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

public:
[System::Runtime::CompilerServices::Extension]
 static ReadOnlySpan<char> Trim(ReadOnlySpan<char> span, char trimChar);
public static ReadOnlySpan<char> Trim(this ReadOnlySpan<char> span, char trimChar);
static member Trim : ReadOnlySpan<char> * char -> ReadOnlySpan<char>
<Extension()>
Public Function Trim (span As ReadOnlySpan(Of Char), trimChar As Char) As ReadOnlySpan(Of Char)

Parameters

trimChar

Char

The specified character to look for and remove.

Returns

The trimmed read-only character span.

Applies to

Trim(Span)

Source:

MemoryExtensions.Trim.cs

Source:

MemoryExtensions.Trim.cs

Source:

MemoryExtensions.Trim.cs

Source:

MemoryExtensions.Trim.cs

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

public:
[System::Runtime::CompilerServices::Extension]
 static Span<char> Trim(Span<char> span);
public static Span<char> Trim(this Span<char> span);
static member Trim : Span<char> -> Span<char>
<Extension()>
Public Function Trim (span As Span(Of Char)) As Span(Of Char)

Parameters

span

Span<Char>

The source span from which the characters are removed.

Returns

The trimmed character span.

Applies to

Trim(Memory)

Source:

MemoryExtensions.Trim.cs

Source:

MemoryExtensions.Trim.cs

Source:

MemoryExtensions.Trim.cs

Source:

MemoryExtensions.Trim.cs

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

public:
[System::Runtime::CompilerServices::Extension]
 static Memory<char> Trim(Memory<char> memory);
public static Memory<char> Trim(this Memory<char> memory);
static member Trim : Memory<char> -> Memory<char>
<Extension()>
Public Function Trim (memory As Memory(Of Char)) As Memory(Of Char)

Parameters

memory

Memory<Char>

The source memory from which the characters are removed.

Returns

The trimmed character memory region.

Applies to

Trim(ReadOnlyMemory)

Source:

MemoryExtensions.Trim.cs

Source:

MemoryExtensions.Trim.cs

Source:

MemoryExtensions.Trim.cs

Source:

MemoryExtensions.Trim.cs

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

public:
[System::Runtime::CompilerServices::Extension]
 static ReadOnlyMemory<char> Trim(ReadOnlyMemory<char> memory);
public static ReadOnlyMemory<char> Trim(this ReadOnlyMemory<char> memory);
static member Trim : ReadOnlyMemory<char> -> ReadOnlyMemory<char>
<Extension()>
Public Function Trim (memory As ReadOnlyMemory(Of Char)) As ReadOnlyMemory(Of Char)

Parameters

Returns

The trimmed character memory region.

Applies to

Trim(ReadOnlySpan)

Source:

MemoryExtensions.Trim.cs

Source:

MemoryExtensions.Trim.cs

Source:

MemoryExtensions.Trim.cs

Source:

MemoryExtensions.Trim.cs

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

public:
[System::Runtime::CompilerServices::Extension]
 static ReadOnlySpan<char> Trim(ReadOnlySpan<char> span);
public static ReadOnlySpan<char> Trim(this ReadOnlySpan<char> span);
static member Trim : ReadOnlySpan<char> -> ReadOnlySpan<char>
<Extension()>
Public Function Trim (span As ReadOnlySpan(Of Char)) As ReadOnlySpan(Of Char)

Parameters

Returns

The trimmed read-only character span.

Applies to

Trim(Memory, ReadOnlySpan)

Source:

MemoryExtensions.Trim.cs

Source:

MemoryExtensions.Trim.cs

Source:

MemoryExtensions.Trim.cs

Source:

MemoryExtensions.Trim.cs

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

public:
generic <typename T>
 where T : IEquatable<T>[System::Runtime::CompilerServices::Extension]
 static Memory<T> Trim(Memory<T> memory, ReadOnlySpan<T> trimElements);
public static Memory<T> Trim<T>(this Memory<T> memory, ReadOnlySpan<T> trimElements) where T : IEquatable<T>;
static member Trim : Memory<'T (requires 'T :> IEquatable<'T>)> * ReadOnlySpan<'T (requires 'T :> IEquatable<'T>)> -> Memory<'T (requires 'T :> IEquatable<'T>)> (requires 'T :> IEquatable<'T>)
<Extension()>
Public Function Trim(Of T As IEquatable(Of T)) (memory As Memory(Of T), trimElements As ReadOnlySpan(Of T)) As Memory(Of T)

Type Parameters

T

The type of the elements in the memory region.

Parameters

memory

Memory

The source memory from which the elements are removed.

trimElements

ReadOnlySpan

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

Trim(Memory, T)

Source:

MemoryExtensions.Trim.cs

Source:

MemoryExtensions.Trim.cs

Source:

MemoryExtensions.Trim.cs

Source:

MemoryExtensions.Trim.cs

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

public:
generic <typename T>
 where T : IEquatable<T>[System::Runtime::CompilerServices::Extension]
 static Memory<T> Trim(Memory<T> memory, T trimElement);
public static Memory<T> Trim<T>(this Memory<T> memory, T trimElement) where T : IEquatable<T>;
static member Trim : Memory<'T (requires 'T :> IEquatable<'T>)> * 'T -> Memory<'T (requires 'T :> IEquatable<'T>)> (requires 'T :> IEquatable<'T>)
<Extension()>
Public Function Trim(Of T As IEquatable(Of T)) (memory As Memory(Of T), trimElement As T) As Memory(Of T)

Type Parameters

T

The type of the elements in the memory region.

Parameters

memory

Memory

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

Trim(ReadOnlyMemory, ReadOnlySpan)

Source:

MemoryExtensions.Trim.cs

Source:

MemoryExtensions.Trim.cs

Source:

MemoryExtensions.Trim.cs

Source:

MemoryExtensions.Trim.cs

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

public:
generic <typename T>
 where T : IEquatable<T>[System::Runtime::CompilerServices::Extension]
 static ReadOnlyMemory<T> Trim(ReadOnlyMemory<T> memory, ReadOnlySpan<T> trimElements);
public static ReadOnlyMemory<T> Trim<T>(this ReadOnlyMemory<T> memory, ReadOnlySpan<T> trimElements) where T : IEquatable<T>;
static member Trim : ReadOnlyMemory<'T (requires 'T :> IEquatable<'T>)> * ReadOnlySpan<'T (requires 'T :> IEquatable<'T>)> -> ReadOnlyMemory<'T (requires 'T :> IEquatable<'T>)> (requires 'T :> IEquatable<'T>)
<Extension()>
Public Function Trim(Of T As IEquatable(Of T)) (memory As ReadOnlyMemory(Of T), trimElements As ReadOnlySpan(Of T)) As ReadOnlyMemory(Of T)

Type Parameters

T

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

Parameters

trimElements

ReadOnlySpan

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

Trim(ReadOnlyMemory, T)

Source:

MemoryExtensions.Trim.cs

Source:

MemoryExtensions.Trim.cs

Source:

MemoryExtensions.Trim.cs

Source:

MemoryExtensions.Trim.cs

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

public:
generic <typename T>
 where T : IEquatable<T>[System::Runtime::CompilerServices::Extension]
 static ReadOnlyMemory<T> Trim(ReadOnlyMemory<T> memory, T trimElement);
public static ReadOnlyMemory<T> Trim<T>(this ReadOnlyMemory<T> memory, T trimElement) where T : IEquatable<T>;
static member Trim : ReadOnlyMemory<'T (requires 'T :> IEquatable<'T>)> * 'T -> ReadOnlyMemory<'T (requires 'T :> IEquatable<'T>)> (requires 'T :> IEquatable<'T>)
<Extension()>
Public Function Trim(Of T As IEquatable(Of T)) (memory As ReadOnlyMemory(Of T), trimElement As T) As ReadOnlyMemory(Of T)

Type Parameters

T

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

Parameters

trimElement

T

The specified element to look for and remove.

Returns

The trimmed read-only memory region.

Applies to

Trim(ReadOnlySpan, ReadOnlySpan)

Source:

MemoryExtensions.Trim.cs

Source:

MemoryExtensions.Trim.cs

Source:

MemoryExtensions.Trim.cs

Source:

MemoryExtensions.Trim.cs

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

public:
generic <typename T>
 where T : IEquatable<T>[System::Runtime::CompilerServices::Extension]
 static ReadOnlySpan<T> Trim(ReadOnlySpan<T> span, ReadOnlySpan<T> trimElements);
public static ReadOnlySpan<T> Trim<T>(this ReadOnlySpan<T> span, ReadOnlySpan<T> trimElements) where T : IEquatable<T>;
static member Trim : ReadOnlySpan<'T (requires 'T :> IEquatable<'T>)> * ReadOnlySpan<'T (requires 'T :> IEquatable<'T>)> -> ReadOnlySpan<'T (requires 'T :> IEquatable<'T>)> (requires 'T :> IEquatable<'T>)
<Extension()>
Public Function Trim(Of T As IEquatable(Of T)) (span As ReadOnlySpan(Of T), trimElements As ReadOnlySpan(Of T)) As ReadOnlySpan(Of T)

Type Parameters

T

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

Parameters

trimElements

ReadOnlySpan

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

Trim(ReadOnlySpan, T)

Source:

MemoryExtensions.Trim.cs

Source:

MemoryExtensions.Trim.cs

Source:

MemoryExtensions.Trim.cs

Source:

MemoryExtensions.Trim.cs

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

public:
generic <typename T>
 where T : IEquatable<T>[System::Runtime::CompilerServices::Extension]
 static ReadOnlySpan<T> Trim(ReadOnlySpan<T> span, T trimElement);
public static ReadOnlySpan<T> Trim<T>(this ReadOnlySpan<T> span, T trimElement) where T : IEquatable<T>;
static member Trim : ReadOnlySpan<'T (requires 'T :> IEquatable<'T>)> * 'T -> ReadOnlySpan<'T (requires 'T :> IEquatable<'T>)> (requires 'T :> IEquatable<'T>)
<Extension()>
Public Function Trim(Of T As IEquatable(Of T)) (span As ReadOnlySpan(Of T), trimElement As T) As ReadOnlySpan(Of T)

Type Parameters

T

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

Parameters

trimElement

T

The specified element to look for and remove.

Returns

The trimmed read-only span.

Applies to

Trim(Span, ReadOnlySpan)

Source:

MemoryExtensions.Trim.cs

Source:

MemoryExtensions.Trim.cs

Source:

MemoryExtensions.Trim.cs

Source:

MemoryExtensions.Trim.cs

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

public:
generic <typename T>
 where T : IEquatable<T>[System::Runtime::CompilerServices::Extension]
 static Span<T> Trim(Span<T> span, ReadOnlySpan<T> trimElements);
public static Span<T> Trim<T>(this Span<T> span, ReadOnlySpan<T> trimElements) where T : IEquatable<T>;
static member Trim : Span<'T (requires 'T :> IEquatable<'T>)> * ReadOnlySpan<'T (requires 'T :> IEquatable<'T>)> -> Span<'T (requires 'T :> IEquatable<'T>)> (requires 'T :> IEquatable<'T>)
<Extension()>
Public Function Trim(Of T As IEquatable(Of T)) (span As Span(Of T), trimElements As ReadOnlySpan(Of T)) As Span(Of T)

Type Parameters

T

The type of the elements in the span.

Parameters

span

Span

The source span from which the elements are removed.

trimElements

ReadOnlySpan

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

Trim(Span, T)

Source:

MemoryExtensions.Trim.cs

Source:

MemoryExtensions.Trim.cs

Source:

MemoryExtensions.Trim.cs

Source:

MemoryExtensions.Trim.cs

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

public:
generic <typename T>
 where T : IEquatable<T>[System::Runtime::CompilerServices::Extension]
 static Span<T> Trim(Span<T> span, T trimElement);
public static Span<T> Trim<T>(this Span<T> span, T trimElement) where T : IEquatable<T>;
static member Trim : Span<'T (requires 'T :> IEquatable<'T>)> * 'T -> Span<'T (requires 'T :> IEquatable<'T>)> (requires 'T :> IEquatable<'T>)
<Extension()>
Public Function Trim(Of T As IEquatable(Of T)) (span As Span(Of T), trimElement As T) As Span(Of T)

Type Parameters

T

The type of the elements in the span.

Parameters

span

Span

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