ImmutableArray<T>.IImmutableList<T>.Replace(T, T, IEqualityComparer<T>) 方法

定义

查找数组中与指定值相等的第一个元素,并将该值替换为指定的新值。Finds the first element in the array equal to the specified value and replaces the value with the specified new value.

 virtual System::Collections::Immutable::IImmutableList<T> ^ System.Collections.Immutable.IImmutableList<T>.Replace(T oldValue, T newValue, System::Collections::Generic::IEqualityComparer<T> ^ equalityComparer) = System::Collections::Immutable::IImmutableList<T>::Replace;
System.Collections.Immutable.IImmutableList<T> IImmutableList<T>.Replace (T oldValue, T newValue, System.Collections.Generic.IEqualityComparer<T> equalityComparer);
Function Replace (oldValue As T, newValue As T, equalityComparer As IEqualityComparer(Of T)) As IImmutableList(Of T) Implements IImmutableList(Of T).Replace

参数

oldValue
T

要在数组中查找并替换的值。The value to find and replace in the array.

newValue
T

用于替换 oldvalue 的值。The value to replace the oldvalue with.

equalityComparer
IEqualityComparer<T>

用于比较值的相等性比较器。The equality comparer to use to compare values.

返回

一个新数组,即使新值和旧值相同,该数组也包含 newValueA new array that contains newValue even if the new and old values are the same.

实现

异常

在数组中找不到 oldValueoldValue is not found in the array.

注解

此成员是显式接口成员的实现。This member is an explicit interface member implementation. 它只能在 ImmutableArray<T> 实例被强制转换为 IImmutableList<T> 接口时使用。It can be used only when the ImmutableArray<T> instance is cast to an IImmutableList<T> interface.

适用于