ImmutableArray<T>.Replace 方法

定义

重载

Replace(T, T)

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

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.

Replace(T, T)

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

public:
 System::Collections::Immutable::ImmutableArray<T> Replace(T oldValue, T newValue);
public System.Collections.Immutable.ImmutableArray<T> Replace (T oldValue, T newValue);
member this.Replace : 'T * 'T -> System.Collections.Immutable.ImmutableArray<'T>
Public Function Replace (oldValue As T, newValue As T) As ImmutableArray(Of T)

参数

oldValue
T

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

newValue
T

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

返回

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

异常

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

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.

public:
 System::Collections::Immutable::ImmutableArray<T> Replace(T oldValue, T newValue, System::Collections::Generic::IEqualityComparer<T> ^ equalityComparer);
public System.Collections.Immutable.ImmutableArray<T> Replace (T oldValue, T newValue, System.Collections.Generic.IEqualityComparer<T> equalityComparer);
member this.Replace : 'T * 'T * System.Collections.Generic.IEqualityComparer<'T> -> System.Collections.Immutable.ImmutableArray<'T>
Public Function Replace (oldValue As T, newValue As T, equalityComparer As IEqualityComparer(Of T)) As ImmutableArray(Of T)

参数

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.

适用于