MemoryExtensions.Replace Method
Definition
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<T>(Span<T>, T, T) |
Replaces all occurrences of |
Replace<T>(ReadOnlySpan<T>, Span<T>, T, T) |
Copies |
Replace<T>(Span<T>, T, T)
- 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<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
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
.
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
- 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.