ImmutableArrayExtensions.SingleOrDefault Metodo
Definizione
Overload
SingleOrDefault<T>(ImmutableArray<T>) |
Restituisce l'unico elemento della matrice o un valore predefinito se la sequenza è vuota. Questo metodo genera un'eccezione se esiste più di un elemento nella sequenza.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>) |
Restituisce l'unico elemento di una sequenza che soddisfa una condizione specificata o un valore predefinito se tale elemento esiste. Questo metodo genera un'eccezione se più di un elemento soddisfa la condizione.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>)
Restituisce l'unico elemento della matrice o un valore predefinito se la sequenza è vuota. Questo metodo genera un'eccezione se esiste più di un elemento nella sequenza.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
Parametri di tipo
- T
Tipo di elemento contenuto dalla raccolta.The type of element contained by the collection.
Parametri
- immutableArray
- ImmutableArray<T>
Matrice.The array.
Restituisce
- T
Elemento nella matrice o il valore predefinito se la matrice è vuota.The element in the array, or the default value if the array is empty.
Eccezioni
source
contiene più di un elemento.source
contains more than one element.
Si applica a
SingleOrDefault<T>(ImmutableArray<T>, Func<T,Boolean>)
Restituisce l'unico elemento di una sequenza che soddisfa una condizione specificata o un valore predefinito se tale elemento esiste. Questo metodo genera un'eccezione se più di un elemento soddisfa la condizione.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
Parametri di tipo
- T
Tipo di elemento contenuto dalla raccolta.The type of element contained by the collection.
Parametri
- immutableArray
- ImmutableArray<T>
Matrice da cui ottenere l'elemento.The array to get the element from.
Condizione che l'elemento deve soddisfare.The condition the element must satisfy.
Restituisce
- T
Elemento, se soddisfa la condizione specificata; in caso contrario, l'elemento predefinito.The element if it satisfies the specified condition; otherwise the default element.
Eccezioni
Più di un elemento soddisfa la condizione in predicate
.More than one element satisfies the condition in predicate
.