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

Definition

Namespace:

System

Assemblies:

netstandard.dll, System.Memory.dll

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

Replace(Span, T, T, IEqualityComparer)
Replace(ReadOnlySpan, Span, T, T, IEqualityComparer)
Replace(Span, T, T) Replaces all occurrences of oldValue with newValue.
Replace(ReadOnlySpan, Span, T, T) Copies source to destination, replacing all occurrences of oldValue with newValue.

Replace(Span, T, T, IEqualityComparer)

Source:

MemoryExtensions.cs

public static void Replace<T>(this Span<T> span, T oldValue, T newValue, System.Collections.Generic.IEqualityComparer<T>? comparer = default);
static member Replace : Span<'T> * 'T * 'T * System.Collections.Generic.IEqualityComparer<'T> -> unit
<Extension()>
Public Sub Replace(Of T) (span As Span(Of T), oldValue As T, newValue As T, Optional comparer As IEqualityComparer(Of T) = Nothing)

Type Parameters

Parameters

Applies to

Replace(ReadOnlySpan, Span, T, T, IEqualityComparer)

Source:

MemoryExtensions.cs

public static void Replace<T>(this ReadOnlySpan<T> source, Span<T> destination, T oldValue, T newValue, System.Collections.Generic.IEqualityComparer<T>? comparer = default);
static member Replace : ReadOnlySpan<'T> * Span<'T> * 'T * 'T * System.Collections.Generic.IEqualityComparer<'T> -> unit
<Extension()>
Public Sub Replace(Of T) (source As ReadOnlySpan(Of T), destination As Span(Of T), oldValue As T, newValue As T, Optional comparer As IEqualityComparer(Of T) = Nothing)

Type Parameters

Parameters

Applies to

Replace(Span, T, T)

Source:

MemoryExtensions.cs

Source:

MemoryExtensions.cs

Source:

MemoryExtensions.cs

Replaces all occurrences of oldValue with newValue.

public:
generic <typename T>
 where T : IEquatable<T>[System::Runtime::CompilerServices::Extension]
 static void Replace(Span<T> span, T oldValue, T newValue);
public static void Replace<T>(this Span<T> span, T oldValue, T newValue) where T : IEquatable<T>;
static member Replace : Span<'T (requires 'T :> IEquatable<'T>)> * 'T * 'T -> unit (requires 'T :> IEquatable<'T>)
<Extension()>
Public Sub Replace(Of T As IEquatable(Of T)) (span As Span(Of T), oldValue As T, newValue As T)

Type Parameters

T

The type of the elements in the span.

Parameters

span

Span

The span in which the elements should be replaced.

oldValue

T

The value to be replaced with newValue.

newValue

T

The value to replace all occurrences of oldValue.

Applies to

Replace(ReadOnlySpan, Span, T, T)

Source:

MemoryExtensions.cs

Source:

MemoryExtensions.cs

Source:

MemoryExtensions.cs

Copies source to destination, replacing all occurrences of oldValue with newValue.

public:
generic <typename T>
 where T : IEquatable<T>[System::Runtime::CompilerServices::Extension]
 static void Replace(ReadOnlySpan<T> source, Span<T> destination, T oldValue, T newValue);
public static void Replace<T>(this ReadOnlySpan<T> source, Span<T> destination, T oldValue, T newValue) where T : IEquatable<T>;
static member Replace : ReadOnlySpan<'T (requires 'T :> IEquatable<'T>)> * Span<'T (requires 'T :> IEquatable<'T>)> * 'T * 'T -> unit (requires 'T :> IEquatable<'T>)
<Extension()>
Public Sub Replace(Of T As IEquatable(Of T)) (source As ReadOnlySpan(Of T), destination As Span(Of T), oldValue As T, newValue As T)

Type Parameters

T

The type of the elements in the spans.

Parameters

destination

Span

The span into which the copied and replaced values should be written.

oldValue

T

The value to be replaced with newValue.

newValue

T

The value to replace all occurrences of oldValue.

Exceptions

The destination span is shorter than the source span. -or-source and destination overlap but don't refer to the same starting location.

Applies to