Skip to content

,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

NameDescription
TSourceThe type of the elements in the source sequence.
TKeyThe type of the lookup key computed for each element in the source sequence.

Parameters

NameTypeDescription
sourceIObservableAn observable sequence to create a lookup for.
keySelectorFuncA function to extract a key from each element.

Returns: IObservable> -- An observable sequence containing a single element with a lookup mapping unique key values onto the corresponding source sequence's elements.

Remarks

The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.

Exceptions

TypeCondition
System.ArgumentNullExceptionsource 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

NameDescription
TSourceThe type of the elements in the source sequence.
TKeyThe type of the lookup key computed for each element in the source sequence.

Parameters

NameTypeDescription
sourceIObservableAn observable sequence to create a lookup for.
keySelectorFuncA function to extract a key from each element.
comparerIEqualityComparerAn equality comparer to compare keys.

Returns: IObservable> -- An observable sequence containing a single element with a lookup mapping unique key values onto the corresponding source sequence's elements.

Remarks

The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.

Exceptions

TypeCondition
System.ArgumentNullExceptionsource 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

NameDescription
TSourceThe type of the elements in the source sequence.
TKeyThe type of the lookup key computed for each element in the source sequence.
TElementThe type of the lookup value computed for each element in the source sequence.

Parameters

NameTypeDescription
sourceIObservableAn observable sequence to create a lookup for.
keySelectorFuncA function to extract a key from each element.
elementSelectorFuncA transform function to produce a result element value from each element.

Returns: IObservable> -- An observable sequence containing a single element with a lookup mapping unique key values onto the corresponding source sequence's elements.

Remarks

The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.

Exceptions

TypeCondition
System.ArgumentNullExceptionsource 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

NameDescription
TSourceThe type of the elements in the source sequence.
TKeyThe type of the lookup key computed for each element in the source sequence.
TElementThe type of the lookup value computed for each element in the source sequence.

Parameters

NameTypeDescription
sourceIObservableAn observable sequence to create a lookup for.
keySelectorFuncA function to extract a key from each element.
elementSelectorFuncA transform function to produce a result element value from each element.
comparerIEqualityComparerAn equality comparer to compare keys.

Returns: IObservable> -- An observable sequence containing a single element with a lookup mapping unique key values onto the corresponding source sequence's elements.

Remarks

The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.

Exceptions

TypeCondition
System.ArgumentNullExceptionsource or keySelector or elementSelector or comparer is null.