)} ,System.Func{--0,System.Boolean})}
Observable.Single(IObservable) method¶
Defined in
Type: Observable
Namespace: System.Reactive.Linq
Assembly: System.Reactive.dll
Applies to
netstandard2.0
Overloads¶
- 1.
public static TSource Single<TSource>(this IObservable<TSource> source) - 2.
public static TSource Single<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 Single<TSource>(this IObservable<TSource> source)
Summary: Returns the only element of an observable sequence, and throws an exception if there is not exactly one element in the observable sequence.
Type parameters
| Name | Description |
|---|---|
TSource | The type of the elements in the source sequence. |
Parameters
| Name | Type | Description |
|---|---|---|
source | IObservable | Source observable sequence. |
Returns: TSource -- The single element in the observable sequence.
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | source is null. |
| System.InvalidOperationException | The source sequence contains more than one element. -or- The source sequence is empty. |
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 Single<TSource>(this IObservable<TSource> source, Func<TSource, bool> predicate)
Summary: Returns the only element of an observable sequence that satisfies the condition in the predicate, and throws an exception if there is not exactly one element matching the predicate in the observable sequence.
Type parameters
| Name | Description |
|---|---|
TSource | The type of the elements in the source sequence. |
Parameters
| Name | Type | Description |
|---|---|---|
source | IObservable | Source observable sequence. |
predicate | Func | A predicate function to evaluate for elements in the source sequence. |
Returns: TSource -- The single element in the observable sequence that satisfies the condition in the predicate.
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | source or predicate is null. |
| System.InvalidOperationException | No element satisfies the condition in the predicate. -or- More than one element satisfies the condition in the predicate. -or- The source sequence is empty. |
See also