共用方式為


Observable.ToLookup < TSource, TKey, TElement > 方法 (IObservable < TSource > , Func TSource, TKey > , Func << TSource, TElement > , IEqualityComparer < TKey >)

根據指定的索引鍵選取器函式、比較子和元素選取器函式,從可觀察的序列建立查閱。

Namespace:System.Reactive.Linq
裝配: System.Reactive.dll) 中的 System.Reactive (

Syntax

'Declaration
<ExtensionAttribute> _
Public Shared Function ToLookup(Of TSource, TKey, TElement) ( _
    source As IObservable(Of TSource), _
    keySelector As Func(Of TSource, TKey), _
    elementSelector As Func(Of TSource, TElement), _
    comparer As IEqualityComparer(Of TKey) _
) As IObservable(Of ILookup(Of TKey, TElement))
'Usage
Dim source As IObservable(Of TSource)
Dim keySelector As Func(Of TSource, TKey)
Dim elementSelector As Func(Of TSource, TElement)
Dim comparer As IEqualityComparer(Of TKey)
Dim returnValue As IObservable(Of ILookup(Of TKey, TElement))

returnValue = source.ToLookup(keySelector, _
    elementSelector, comparer)
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
)
[ExtensionAttribute]
public:
generic<typename TSource, typename TKey, typename TElement>
static IObservable<ILookup<TKey, TElement>^>^ ToLookup(
    IObservable<TSource>^ source, 
    Func<TSource, TKey>^ keySelector, 
    Func<TSource, TElement>^ elementSelector, 
    IEqualityComparer<TKey>^ comparer
)
static member ToLookup : 
        source:IObservable<'TSource> * 
        keySelector:Func<'TSource, 'TKey> * 
        elementSelector:Func<'TSource, 'TElement> * 
        comparer:IEqualityComparer<'TKey> -> IObservable<ILookup<'TKey, 'TElement>> 
JScript does not support generic types and methods.

類型參數

  • TSource
    來源的類型。
  • TKey
    索引鍵類型。
  • TElement
    項目的型別。

參數

  • keySelector
    類型:System.Func< TSource、TKey>
    用來從各個項目擷取索引鍵的函式。
  • elementSelector
    類型:System.Func< TSource、TElement>
    用來從每個項目產生結果項目值的轉換函式。

傳回值

類型:System.IObservable<ILookup< TKey、 TElement>>
根據指定的索引鍵選取器函式、比較子和元素選取器函式,從可觀察序列查閱。

使用注意事項

在 Visual Basic 和 C# 中,您可以在IObservable< TSource > 類型的任何物件上呼叫此方法作為實例方法。 使用執行個體方法語法呼叫這個方法時,請省略第一個參數。 如需詳細資訊,請參閱

另請參閱

參考

Observable 類別

ToLookup 多載

System.Reactive.Linq 命名空間