Lookup<TKey,TElement>.Item[TKey] 屬性

定義

取得以指定之索引鍵編製索引的值集合。

public:
 property System::Collections::Generic::IEnumerable<TElement> ^ default[TKey] { System::Collections::Generic::IEnumerable<TElement> ^ get(TKey key); };
public System.Collections.Generic.IEnumerable<TElement> this[TKey key] { get; }
member this.Item('Key) : seq<'Element>
Default Public ReadOnly Property Item(key As TKey) As IEnumerable(Of TElement)

參數

key
TKey

所需之值集合的索引鍵。

屬性值

IEnumerable<TElement>

以指定之索引鍵編製索引的值集合。

實作

範例

下列範例示範如何使用 Item[] 直接編制索引至 Lookup<TKey,TElement>。 此程式代碼範例是提供給 類別之較大範例的 Lookup<TKey,TElement> 一部分。

// Select a collection of Packages by indexing directly into the Lookup.
IEnumerable<string> cgroup = lookup['C'];
' Select a collection of Packages by indexing directly into the Lookup.
Dim cgroup As System.Collections.Generic.IEnumerable(Of String) = lookup("C"c)

備註

這個索引屬性可讓您使用下列語法,在 中編製值集合的 Lookup<TKey,TElement> 索引: myLookup[key] 在 Visual C# 或 myLookup(key) Visual Basic 中。 key如果在集合中找不到 ,則會傳回空序列。

適用於