Skip to content

)} ,System.Func{--0,System.Boolean})}

Observable.FirstOrDefault(IObservable) method

Defined in

Type: Observable Namespace: System.Reactive.Linq Assembly: System.Reactive.dll

Applies to

netstandard2.0

Overloads

  • 1. public static TSource FirstOrDefault<TSource>(this IObservable<TSource> source)
  • 2. public static TSource FirstOrDefault<TSource>(this IObservable<TSource> source, Func<TSource, bool> predicate)

1. Overload

Deprecated

This blocking operation is no longer supported. Instead, use the async version in combination with C# and Visual Basic async/await support. In case you need a blocking operation, use Wait or convert the resulting observable sequence to a Task object and block.

Attributes: [Obsolete("This blocking operation is no longer supported. Instead, use the async version in combination with C# and Visual Basic async/await support. In case you need a blocking operation, use Wait or convert the resulting observable sequence to a Task object and block.")]

public static TSource FirstOrDefault<TSource>(this IObservable<TSource> source)

Summary: Returns the first element of an observable sequence, or a default value if no such element exists.

Type parameters

NameDescription
TSourceThe type of the elements in the source sequence.

Parameters

NameTypeDescription
sourceIObservableSource observable sequence.

Returns: TSource -- The first element in the observable sequence, or a default value if no such element exists.

Exceptions

TypeCondition
System.ArgumentNullExceptionsource is null.

See also

2. Overload

Deprecated

This blocking operation is no longer supported. Instead, use the async version in combination with C# and Visual Basic async/await support. In case you need a blocking operation, use Wait or convert the resulting observable sequence to a Task object and block.

Attributes: [Obsolete("This blocking operation is no longer supported. Instead, use the async version in combination with C# and Visual Basic async/await support. In case you need a blocking operation, use Wait or convert the resulting observable sequence to a Task object and block.")]

public static TSource FirstOrDefault<TSource>(this IObservable<TSource> source, Func<TSource, bool> predicate)

Summary: Returns the first element of an observable sequence that satisfies the condition in the predicate, or a default value if no such element exists.

Type parameters

NameDescription
TSourceThe type of the elements in the source sequence.

Parameters

NameTypeDescription
sourceIObservableSource observable sequence.
predicateFuncA predicate function to evaluate for elements in the source sequence.

Returns: TSource -- The first element in the observable sequence that satisfies the condition in the predicate, or a default value if no such element exists.

Exceptions

TypeCondition
System.ArgumentNullExceptionsource or predicate is null.

See also