Lookup<TKey, TElement>.GetEnumerator Method
Microsoft Silverlight will reach end of support after October 2021. Learn more.
Returns a generic enumerator that iterates through the Lookup<TKey, TElement>.
Namespace: System.Linq
Assembly: System.Core (in System.Core.dll)
Syntax
'Declaration
Public Function GetEnumerator As IEnumerator(Of IGrouping(Of TKey, TElement))
public IEnumerator<IGrouping<TKey, TElement>> GetEnumerator()
Return Value
Type: System.Collections.Generic.IEnumerator<IGrouping<TKey, TElement>>
An enumerator for the Lookup<TKey, TElement>.
Implements
Examples
The following example demonstrates how to use GetEnumerator to iterate through the keys and values of a Lookup<TKey, TElement>. This code example is part of a larger example provided for the Lookup<TKey, TElement> class.
Dim output As New System.Text.StringBuilder
' Iterate through each Example in the Lookup and output the contents.
For Each packageGroup As IGrouping(Of Char, String) In lookup
' Print the key value of the Example.
output.AppendLine(packageGroup.Key)
' Iterate through each value in the Example and print its value.
For Each str As String In packageGroup
output.AppendLine(String.Format(" {0}", str))
Next
Next
' Display the output.
outputBlock.Text &= output.ToString() & vbCrLf
// Iterate through each Example in the Lookup and output the contents.
foreach (IGrouping<char, string> packageGroup in lookup)
{
// Print the key value of the Example.
outputBlock.Text += packageGroup.Key + "\n";
// Iterate through each value in the Example and print its value.
foreach (string str in packageGroup)
outputBlock.Text += String.Format(" {0}", str) + "\n";
}
Version Information
Silverlight
Supported in: 5, 4, 3
Silverlight for Windows Phone
Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0
XNA Framework
Supported in: Xbox 360, Windows Phone OS 7.0
Platforms
For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.