MemoryExtensions.Replace 方法

定义

重载

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

将所有 oldValue 项都替换为 newValue

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

source将 复制到 destination,并将 的所有匹配oldValue项替换为 newValue

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

Source:
MemoryExtensions.cs
Source:
MemoryExtensions.cs

将所有 oldValue 项都替换为 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)

类型参数

T

跨度中元素的类型。

参数

span
Span<T>

应替换元素的跨度。

oldValue
T

要替换为 newValue的值。

newValue
T

要替换 的所有匹配项的值 oldValue

适用于

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

Source:
MemoryExtensions.cs
Source:
MemoryExtensions.cs

source将 复制到 destination,并将 的所有匹配oldValue项替换为 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)

类型参数

T

范围中元素的类型。

参数

source
ReadOnlySpan<T>

要复制的跨度。

destination
Span<T>

复制的值和替换的值应写入其中的跨度。

oldValue
T

要替换为 newValue的值。

newValue
T

要替换 的所有匹配项的值 oldValue

例外

范围 destinationsource 范围短。 - 或 - sourcedestination 重叠,但不引用相同的起始位置。

适用于