ImmutableArrayExtensions.ElementAtOrDefault<T>(ImmutableArray<T>, Int32) 方法

定义

返回序列中指定索引处的元素;如果索引超出范围,则返回默认值。Returns the element at a specified index in a sequence or a default value if the index is out of range.

public:
generic <typename T>
[System::Runtime::CompilerServices::Extension]
 static T ElementAtOrDefault(System::Collections::Immutable::ImmutableArray<T> immutableArray, int index);
public static T ElementAtOrDefault<T> (this System.Collections.Immutable.ImmutableArray<T> immutableArray, int index);
static member ElementAtOrDefault : System.Collections.Immutable.ImmutableArray<'T> * int -> 'T
<Extension()>
Public Function ElementAtOrDefault(Of T) (immutableArray As ImmutableArray(Of T), index As Integer) As T

类型参数

T

集合包含的元素的类型。The type of element contained by the collection.

参数

immutableArray
ImmutableArray<T>

要在其中查找元素的数组。The array to find an element in.

index
Int32

要检索的元素的索引。The index for the element to retrieve.

返回

T

指定索引处的项;如果找不到该索引,则为默认值。The item at the specified index, or the default value if the index is not found.

适用于