Observable.ToDictionary < TSource, TKey > 方法 (IObservable < TSource, Func < TSource > , TKey, IEqualityComparer < TKey >>)
根據指定的索引鍵選取器函式和比較子,從可觀察序列建立字典。
Namespace:System.Reactive.Linq
裝配: System.Reactive.dll) 中的 System.Reactive (
Syntax
'Declaration
<ExtensionAttribute> _
Public Shared Function ToDictionary(Of TSource, TKey) ( _
source As IObservable(Of TSource), _
keySelector As Func(Of TSource, TKey), _
comparer As IEqualityComparer(Of TKey) _
) As IObservable(Of IDictionary(Of TKey, TSource))
'Usage
Dim source As IObservable(Of TSource)
Dim keySelector As Func(Of TSource, TKey)
Dim comparer As IEqualityComparer(Of TKey)
Dim returnValue As IObservable(Of IDictionary(Of TKey, TSource))
returnValue = source.ToDictionary(keySelector, _
comparer)
public static IObservable<IDictionary<TKey, TSource>> ToDictionary<TSource, TKey>(
this IObservable<TSource> source,
Func<TSource, TKey> keySelector,
IEqualityComparer<TKey> comparer
)
[ExtensionAttribute]
public:
generic<typename TSource, typename TKey>
static IObservable<IDictionary<TKey, TSource>^>^ ToDictionary(
IObservable<TSource>^ source,
Func<TSource, TKey>^ keySelector,
IEqualityComparer<TKey>^ comparer
)
static member ToDictionary :
source:IObservable<'TSource> *
keySelector:Func<'TSource, 'TKey> *
comparer:IEqualityComparer<'TKey> -> IObservable<IDictionary<'TKey, 'TSource>>
JScript does not support generic types and methods.
類型參數
- TSource
來源的類型。
- TKey
索引鍵類型。
參數
- source
類型:System.IObservable< TSource>
要為其建立字典的可觀察序列。
- keySelector
類型:System.Func< TSource、TKey>
用來從各個項目擷取索引鍵的函式。
- 比較
類型:System.Collections.Generic.IEqualityComparer< TKey>
要比較索引鍵的相等比較子。
傳回值
類型:System.IObservable<IDictionary< TKey、TSource>>
根據指定的索引鍵選取器函式和比較子,從可觀察序列的字典。
使用注意事項
在 Visual Basic 和 C# 中,您可以在IObservable< TSource > 類型的任何物件上呼叫此方法作為實例方法。 使用執行個體方法語法呼叫這個方法時,請省略第一個參數。 如需詳細資訊,請參閱 或 。