Lookup<TKey,TElement>.GetEnumerator 方法 
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
返回一个循环访问 Lookup<TKey,TElement> 的泛型枚举数。
public:
 virtual System::Collections::Generic::IEnumerator<System::Linq::IGrouping<TKey, TElement> ^> ^ GetEnumerator();public System.Collections.Generic.IEnumerator<System.Linq.IGrouping<TKey,TElement>> GetEnumerator ();abstract member GetEnumerator : unit -> System.Collections.Generic.IEnumerator<System.Linq.IGrouping<'Key, 'Element>>
override this.GetEnumerator : unit -> System.Collections.Generic.IEnumerator<System.Linq.IGrouping<'Key, 'Element>>Public Function GetEnumerator () As IEnumerator(Of IGrouping(Of TKey, TElement))Public Iterator Overridable NotOverridable Function GetEnumerator () As IEnumerator(Of IGrouping(Of TKey, TElement))返回
		IEnumerator<IGrouping<TKey,TElement>>
		
	
	用于 Lookup<TKey,TElement> 的枚举数。
实现
示例
以下示例演示如何使用 GetEnumerator 来循环访问 的 Lookup<TKey,TElement>键和值。 此代码示例是为 Lookup<TKey,TElement> 类提供的一个更大示例的一部分。
// Iterate through each IGrouping in the Lookup and output the contents.
foreach (IGrouping<char, string> packageGroup in lookup)
{
    // Print the key value of the IGrouping.
    Console.WriteLine(packageGroup.Key);
    // Iterate through each value in the IGrouping and print its value.
    foreach (string str in packageGroup)
        Console.WriteLine("    {0}", str);
}
Dim output As New System.Text.StringBuilder
' Iterate through each IGrouping in the Lookup and output the contents.
For Each packageGroup As IGrouping(Of Char, String) In lookup
    ' Print the key value of the IGrouping.
    output.AppendLine(packageGroup.Key)
    ' Iterate through each value in the IGrouping and print its value.
    For Each str As String In packageGroup
        output.AppendLine(String.Format("    {0}", str))
    Next
Next
' Display the output.
MsgBox(output.ToString())