MemoryExtensions.Replace 方法

定義

多載

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

將所有出現的 oldValue 專案取代為 newValue

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

sourcedestination 複製到 ,將 的所有出現專案 oldValue 取代為 newValue

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

來源:
MemoryExtensions.cs
來源:
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)

來源:
MemoryExtensions.cs
來源:
MemoryExtensions.cs

sourcedestination 複製到 ,將 的所有出現專案 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 重迭,但不參考相同的起始位置。

適用於