ParallelEnumerable.FirstOrDefault Método
Definição
Retornará o primeiro elemento de uma sequência paralela ou um valor padrão, se a sequência não contiver elementos.Returns the first element of a parallel sequence, or a default value if the sequence contains no elements.
Sobrecargas
| FirstOrDefault<TSource>(ParallelQuery<TSource>) |
Retornará o primeiro elemento de uma sequência paralela ou um valor padrão, se a sequência não contiver elementos.Returns the first element of a parallel sequence, or a default value if the sequence contains no elements. |
| FirstOrDefault<TSource>(ParallelQuery<TSource>, Func<TSource,Boolean>) |
Retorna o primeiro elemento da sequência paralela que satisfaz a uma condição ou um valor padrão, caso esse elemento não seja encontrado.Returns the first element of the parallel sequence that satisfies a condition or a default value if no such element is found. |
FirstOrDefault<TSource>(ParallelQuery<TSource>)
Retornará o primeiro elemento de uma sequência paralela ou um valor padrão, se a sequência não contiver elementos.Returns the first element of a parallel sequence, or a default value if the sequence contains no elements.
public:
generic <typename TSource>
[System::Runtime::CompilerServices::Extension]
static TSource FirstOrDefault(System::Linq::ParallelQuery<TSource> ^ source);
public static TSource FirstOrDefault<TSource> (this System.Linq.ParallelQuery<TSource> source);
public static TSource? FirstOrDefault<TSource> (this System.Linq.ParallelQuery<TSource> source);
static member FirstOrDefault : System.Linq.ParallelQuery<'Source> -> 'Source
<Extension()>
Public Function FirstOrDefault(Of TSource) (source As ParallelQuery(Of TSource)) As TSource
Parâmetros de tipo
- TSource
O tipo dos elementos de source.The type of the elements of source.
Parâmetros
- source
- ParallelQuery<TSource>
A sequência da qual retornar o primeiro elemento.The sequence to return the first element of.
Retornos
- TSource
default(TSource) se source estiver vazio; caso contrário, o primeiro elemento em source.default(TSource) if source is empty; otherwise, the first element in source.
Exceções
A consulta foi cancelada com o token transmitido pelo WithCancellation.The query was canceled with the token passed in through WithCancellation.
source é uma referência nula (Nada no Visual Basic).source is a null reference (Nothing in Visual Basic).
Uma ou mais exceções ocorreram durante a avaliação da consulta.One or more exceptions occurred during the evaluation of the query.
Comentários
Se a consulta não for ordenada, o primeiro elemento será não determinístico.If the query is not ordered, then the first element is non-deterministic. Para saber mais, veja Preservação da ordem em PLINQ.For more information, see Order Preservation in PLINQ.
Aplica-se a
FirstOrDefault<TSource>(ParallelQuery<TSource>, Func<TSource,Boolean>)
Retorna o primeiro elemento da sequência paralela que satisfaz a uma condição ou um valor padrão, caso esse elemento não seja encontrado.Returns the first element of the parallel sequence that satisfies a condition or a default value if no such element is found.
public:
generic <typename TSource>
[System::Runtime::CompilerServices::Extension]
static TSource FirstOrDefault(System::Linq::ParallelQuery<TSource> ^ source, Func<TSource, bool> ^ predicate);
public static TSource FirstOrDefault<TSource> (this System.Linq.ParallelQuery<TSource> source, Func<TSource,bool> predicate);
public static TSource? FirstOrDefault<TSource> (this System.Linq.ParallelQuery<TSource> source, Func<TSource,bool> predicate);
static member FirstOrDefault : System.Linq.ParallelQuery<'Source> * Func<'Source, bool> -> 'Source
<Extension()>
Public Function FirstOrDefault(Of TSource) (source As ParallelQuery(Of TSource), predicate As Func(Of TSource, Boolean)) As TSource
Parâmetros de tipo
- TSource
O tipo dos elementos de source.The type of the elements of source.
Parâmetros
- source
- ParallelQuery<TSource>
A sequência da qual retornar um elemento.The sequence to return an element from.
Uma função para testar cada elemento em relação a uma condição.A function to test each element for a condition.
Retornos
- TSource
default(TSource) se source estiver vazio ou se nenhum elemento for aprovado no teste especificado pelo predicado; caso contrário, o primeiro elemento em source que for aprovado no teste especificado pelo predicado.default(TSource) if source is empty or if no element passes the test specified by predicate; otherwise, the first element in source that passes the test specified by predicate.
Exceções
A consulta foi cancelada com o token transmitido pelo WithCancellation.The query was canceled with the token passed in through WithCancellation.
source ou predicate é uma referência nula (Nothing no Visual Basic).source or predicate is a null reference (Nothing in Visual Basic).
Uma ou mais exceções ocorreram durante a avaliação da consulta.One or more exceptions occurred during the evaluation of the query.
Comentários
Se a consulta não for ordenada, o primeiro elemento será não determinístico.If the query is not ordered, then the first element is non-deterministic. Para saber mais, veja Preservação da ordem em PLINQ.For more information, see Order Preservation in PLINQ.