ImmutableArrayExtensions.SingleOrDefault Método

Definição

Sobrecargas

SingleOrDefault<T>(ImmutableArray<T>)

Retorna o único elemento da matriz ou um valor padrão se a sequência é vazia; esse método gera uma exceção se há mais de um elemento na sequência.Returns the only element of the array, or a default value if the sequence is empty; this method throws an exception if there is more than one element in the sequence.

SingleOrDefault<T>(ImmutableArray<T>, Func<T,Boolean>)

Retorna o único elemento de uma sequência que satisfaz uma condição especificada ou um valor padrão se esse elemento não existir. Esse método lança uma exceção se mais de um elemento satisfizer a condição.Returns the only element of a sequence that satisfies a specified condition or a default value if no such element exists; this method throws an exception if more than one element satisfies the condition.

SingleOrDefault<T>(ImmutableArray<T>)

Retorna o único elemento da matriz ou um valor padrão se a sequência é vazia; esse método gera uma exceção se há mais de um elemento na sequência.Returns the only element of the array, or a default value if the sequence is empty; this method throws an exception if there is more than one element in the sequence.

public:
generic <typename T>
[System::Runtime::CompilerServices::Extension]
 static T SingleOrDefault(System::Collections::Immutable::ImmutableArray<T> immutableArray);
public static T SingleOrDefault<T> (this System.Collections.Immutable.ImmutableArray<T> immutableArray);
public static T? SingleOrDefault<T> (this System.Collections.Immutable.ImmutableArray<T> immutableArray);
static member SingleOrDefault : System.Collections.Immutable.ImmutableArray<'T> -> 'T
<Extension()>
Public Function SingleOrDefault(Of T) (immutableArray As ImmutableArray(Of T)) As T

Parâmetros de tipo

T

O tipo de elemento contido na coleção.The type of element contained by the collection.

Parâmetros

immutableArray
ImmutableArray<T>

A matriz.The array.

Retornos

T

O elemento da matriz ou o valor padrão, se a matriz está vazia.The element in the array, or the default value if the array is empty.

Exceções

source contém mais de um elemento.source contains more than one element.

Aplica-se a

SingleOrDefault<T>(ImmutableArray<T>, Func<T,Boolean>)

Retorna o único elemento de uma sequência que satisfaz uma condição especificada ou um valor padrão se esse elemento não existir. Esse método lança uma exceção se mais de um elemento satisfizer a condição.Returns the only element of a sequence that satisfies a specified condition or a default value if no such element exists; this method throws an exception if more than one element satisfies the condition.

public:
generic <typename T>
[System::Runtime::CompilerServices::Extension]
 static T SingleOrDefault(System::Collections::Immutable::ImmutableArray<T> immutableArray, Func<T, bool> ^ predicate);
public static T SingleOrDefault<T> (this System.Collections.Immutable.ImmutableArray<T> immutableArray, Func<T,bool> predicate);
public static T? SingleOrDefault<T> (this System.Collections.Immutable.ImmutableArray<T> immutableArray, Func<T,bool> predicate);
static member SingleOrDefault : System.Collections.Immutable.ImmutableArray<'T> * Func<'T, bool> -> 'T
<Extension()>
Public Function SingleOrDefault(Of T) (immutableArray As ImmutableArray(Of T), predicate As Func(Of T, Boolean)) As T

Parâmetros de tipo

T

O tipo de elemento contido na coleção.The type of element contained by the collection.

Parâmetros

immutableArray
ImmutableArray<T>

A matriz da qual obter o elemento.The array to get the element from.

predicate
Func<T,Boolean>

A condição que o elemento deve satisfazer.The condition the element must satisfy.

Retornos

T

O elemento, se ele atende à condição especificada; caso contrário, o elemento padrão.The element if it satisfies the specified condition; otherwise the default element.

Exceções

Mais de um elemento satisfaz a condição na predicate.More than one element satisfies the condition in predicate.

Aplica-se a