Прочетете на английски Редактиране

Споделяне чрез


MemoryExtensions.Replace Method

Definition

Overloads

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

Replaces all occurrences of oldValue with newValue.

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

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

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

C#
public static void Replace<T>(this ReadOnlySpan<T> source, Span<T> destination, T oldValue, T newValue, System.Collections.Generic.IEqualityComparer<T>? comparer = default);

Type Parameters

T

Parameters

destination
Span<T>
oldValue
T
newValue
T

Applies to

.NET 10
Продукт Версии
.NET 10

Replace<T>(Span<T>, T, T, IEqualityComparer<T>)

C#
public static void Replace<T>(this Span<T> span, T oldValue, T newValue, System.Collections.Generic.IEqualityComparer<T>? comparer = default);

Type Parameters

T

Parameters

span
Span<T>
oldValue
T
newValue
T

Applies to

.NET 10
Продукт Версии
.NET 10

Replace<T>(Span<T>, T, T)

Source:
MemoryExtensions.cs
Source:
MemoryExtensions.cs

Replaces all occurrences of oldValue with newValue.

C#
public static void Replace<T>(this Span<T> span, T oldValue, T newValue) where T : IEquatable<T>;

Type Parameters

T

The type of the elements in the span.

Parameters

span
Span<T>

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

.NET 10 и други версии
Продукт Версии
.NET 8, 9, 10

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

Source:
MemoryExtensions.cs
Source:
MemoryExtensions.cs

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

C#
public static void Replace<T>(this ReadOnlySpan<T> source, Span<T> destination, T oldValue, T newValue) where T : IEquatable<T>;

Type Parameters

T

The type of the elements in the spans.

Parameters

source
ReadOnlySpan<T>

The span to copy.

destination
Span<T>

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

.NET 10 и други версии
Продукт Версии
.NET 8, 9, 10