,System.Func{--0,--1})} ,System.Func{--0,--1},System.Collections.Generic.IEqualityComparer{--1})} ,System.Func{--0,--1},System.Func{--0,--2})} ,System.Func{--0,--1},System.Func{--0,--2},System.Collections.Generic.IEqualityComparer{--1})}
Observable.ToLookup(IObservable, Func) method¶
Defined in
Type: Observable
Namespace: System.Reactive.Linq
Assembly: System.Reactive.dll
Applies to
netstandard2.0
Overloads¶
- 1.
public static IObservable<ILookup<TKey, TSource>> ToLookup<TSource, TKey>(this IObservable<TSource> source, Func<TSource, TKey> keySelector) - 2.
public static IObservable<ILookup<TKey, TSource>> ToLookup<TSource, TKey>(this IObservable<TSource> source, Func<TSource, TKey> keySelector, IEqualityComparer<TKey> comparer) - 3.
public static IObservable<ILookup<TKey, TElement>> ToLookup<TSource, TKey, TElement>(this IObservable<TSource> source, Func<TSource, TKey> keySelector, Func<TSource, TElement> elementSelector) - 4.
public static IObservable<ILookup<TKey, TElement>> ToLookup<TSource, TKey, TElement>(this IObservable<TSource> source, Func<TSource, TKey> keySelector, Func<TSource, TElement> elementSelector, IEqualityComparer<TKey> comparer)
1. Overload¶
public static IObservable<ILookup<TKey, TSource>> ToLookup<TSource, TKey>(this IObservable<TSource> source, Func<TSource, TKey> keySelector)
Summary: Creates a lookup from an observable sequence according to a specified key selector function.
Type parameters
| Name | Description |
|---|---|
TSource | The type of the elements in the source sequence. |
TKey | The type of the lookup key computed for each element in the source sequence. |
Parameters
| Name | Type | Description |
|---|---|---|
source | IObservable | An observable sequence to create a lookup for. |
keySelector | Func | A function to extract a key from each element. |
Returns: IObservable
Remarks
The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | source or keySelector is null. |
2. Overload¶
public static IObservable<ILookup<TKey, TSource>> ToLookup<TSource, TKey>(this IObservable<TSource> source, Func<TSource, TKey> keySelector, IEqualityComparer<TKey> comparer)
Summary: Creates a lookup from an observable sequence according to a specified key selector function, and a comparer.
Type parameters
| Name | Description |
|---|---|
TSource | The type of the elements in the source sequence. |
TKey | The type of the lookup key computed for each element in the source sequence. |
Parameters
| Name | Type | Description |
|---|---|---|
source | IObservable | An observable sequence to create a lookup for. |
keySelector | Func | A function to extract a key from each element. |
comparer | IEqualityComparer | An equality comparer to compare keys. |
Returns: IObservable
Remarks
The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | source or keySelector or comparer is null. |
3. Overload¶
public static IObservable<ILookup<TKey, TElement>> ToLookup<TSource, TKey, TElement>(this IObservable<TSource> source, Func<TSource, TKey> keySelector, Func<TSource, TElement> elementSelector)
Summary: Creates a lookup from an observable sequence according to a specified key selector function, and an element selector function.
Type parameters
| Name | Description |
|---|---|
TSource | The type of the elements in the source sequence. |
TKey | The type of the lookup key computed for each element in the source sequence. |
TElement | The type of the lookup value computed for each element in the source sequence. |
Parameters
| Name | Type | Description |
|---|---|---|
source | IObservable | An observable sequence to create a lookup for. |
keySelector | Func | A function to extract a key from each element. |
elementSelector | Func | A transform function to produce a result element value from each element. |
Returns: IObservable
Remarks
The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | source or keySelector or elementSelector is null. |
4. Overload¶
public static IObservable<ILookup<TKey, TElement>> ToLookup<TSource, TKey, TElement>(this IObservable<TSource> source, Func<TSource, TKey> keySelector, Func<TSource, TElement> elementSelector, IEqualityComparer<TKey> comparer)
Summary: Creates a lookup from an observable sequence according to a specified key selector function, a comparer, and an element selector function.
Type parameters
| Name | Description |
|---|---|
TSource | The type of the elements in the source sequence. |
TKey | The type of the lookup key computed for each element in the source sequence. |
TElement | The type of the lookup value computed for each element in the source sequence. |
Parameters
| Name | Type | Description |
|---|---|---|
source | IObservable | An observable sequence to create a lookup for. |
keySelector | Func | A function to extract a key from each element. |
elementSelector | Func | A transform function to produce a result element value from each element. |
comparer | IEqualityComparer | An equality comparer to compare keys. |
Returns: IObservable
Remarks
The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | source or keySelector or elementSelector or comparer is null. |