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[] 直接索引到 a 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 序列,则返回空序列。

适用于