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>에 대한 열거자입니다.
구현
예제
다음 예제에서는 키와 값을 Lookup<TKey,TElement>반복 하는 데 사용 GetEnumerator 하는 방법을 보여 줍니다. 이 코드 예제는에 대해 제공 된 큰 예제의 일부는 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())