ImmutableArrayExtensions.FirstOrDefault 方法
定义
重载
| FirstOrDefault<T>(ImmutableArray<T>) |
返回序列中的第一个元素;如果序列中不包含任何元素,则返回默认值。Returns the first element of a sequence, or a default value if the sequence contains no elements. |
| FirstOrDefault<T>(ImmutableArray<T>.Builder) |
返回集合中的第一个元素;如果集合为空,则返回默认值。Returns the first element in the collection, or the default value if the collection is empty. |
| FirstOrDefault<T>(ImmutableArray<T>, Func<T,Boolean>) |
返回序列中满足条件的第一个元素;如果未找到这样的元素,则返回默认值。Returns the first element of the sequence that satisfies a condition or a default value if no such element is found. |
FirstOrDefault<T>(ImmutableArray<T>)
返回序列中的第一个元素;如果序列中不包含任何元素,则返回默认值。Returns the first element of a sequence, or a default value if the sequence contains no elements.
public:
generic <typename T>
[System::Runtime::CompilerServices::Extension]
static T FirstOrDefault(System::Collections::Immutable::ImmutableArray<T> immutableArray);
public static T FirstOrDefault<T> (this System.Collections.Immutable.ImmutableArray<T> immutableArray);
public static T? FirstOrDefault<T> (this System.Collections.Immutable.ImmutableArray<T> immutableArray);
static member FirstOrDefault : System.Collections.Immutable.ImmutableArray<'T> -> 'T
<Extension()>
Public Function FirstOrDefault(Of T) (immutableArray As ImmutableArray(Of T)) As T
类型参数
- T
集合包含的元素的类型。The type of element contained by the collection.
参数
- immutableArray
- ImmutableArray<T>
要从中检索项的数组。The array to retrieve items from.
返回
- T
列表中的第一个项(如果已找到);否则,为项类型的默认值。The first item in the list, if found; otherwise the default value for the item type.
适用于
FirstOrDefault<T>(ImmutableArray<T>.Builder)
返回集合中的第一个元素;如果集合为空,则返回默认值。Returns the first element in the collection, or the default value if the collection is empty.
public:
generic <typename T>
[System::Runtime::CompilerServices::Extension]
static T FirstOrDefault(System::Collections::Immutable::ImmutableArray<T>::Builder ^ builder);
public static T FirstOrDefault<T> (this System.Collections.Immutable.ImmutableArray<T>.Builder builder);
public static T? FirstOrDefault<T> (this System.Collections.Immutable.ImmutableArray<T>.Builder builder);
static member FirstOrDefault : System.Collections.Immutable.ImmutableArray<'T>.Builder -> 'T
<Extension()>
Public Function FirstOrDefault(Of T) (builder As ImmutableArray(Of T).Builder) As T
类型参数
- T
生成器中的项类型。The type of item in the builder.
参数
- builder
- ImmutableArray<T>.Builder
要从中检索元素的生成器。The builder to retrieve an element from.
返回
- T
列表中的第一个项(如果已找到);否则,为项类型的默认值。The first item in the list, if found; otherwise the default value for the item type.
适用于
FirstOrDefault<T>(ImmutableArray<T>, Func<T,Boolean>)
返回序列中满足条件的第一个元素;如果未找到这样的元素,则返回默认值。Returns the first element of the sequence that satisfies a condition or a default value if no such element is found.
public:
generic <typename T>
[System::Runtime::CompilerServices::Extension]
static T FirstOrDefault(System::Collections::Immutable::ImmutableArray<T> immutableArray, Func<T, bool> ^ predicate);
public static T FirstOrDefault<T> (this System.Collections.Immutable.ImmutableArray<T> immutableArray, Func<T,bool> predicate);
public static T? FirstOrDefault<T> (this System.Collections.Immutable.ImmutableArray<T> immutableArray, Func<T,bool> predicate);
static member FirstOrDefault : System.Collections.Immutable.ImmutableArray<'T> * Func<'T, bool> -> 'T
<Extension()>
Public Function FirstOrDefault(Of T) (immutableArray As ImmutableArray(Of T), predicate As Func(Of T, Boolean)) As T
类型参数
- T
集合包含的元素的类型。The type of element contained by the collection.
参数
- immutableArray
- ImmutableArray<T>
要从中检索元素的数组。The array to retrieve elements from.
委托,用于定义要搜索的元素的条件。The delegate that defines the conditions of the element to search for.
返回
- T
列表中的第一个项(如果已找到);否则,为项类型的默认值。The first item in the list, if found; otherwise the default value for the item type.