Lookup<TKey,TElement>.Item[TKey] 属性
定义
获取由指定的键编制索引的值的集合。Gets the collection of values indexed by the specified key.
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
所需值集合的键。The key of the desired collection of values.
属性值
- IEnumerable<TElement>
由指定键编制索引的值的集合。The collection of values indexed by the specified key.
实现
示例
下面的示例演示如何使用 Item[] 直接索引到中 Lookup<TKey,TElement> 。The following example demonstrates how to use Item[] to index directly into a Lookup<TKey,TElement>. 此代码示例是为类提供的更大示例的一部分 Lookup<TKey,TElement> 。This code example is part of a larger example provided for the Lookup<TKey,TElement> class.
// 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 中。This indexed property provides the ability to index a specific collection of values in the Lookup<TKey,TElement> by using the following syntax: myLookup[key] in Visual C# or myLookup(key) in Visual Basic. 如果在 key 集合中找不到,则返回空序列。If the key is not found in the collection, an empty sequence is returned.