ToEnumerable()
Convert an IEnumerator<T> to IEnumerable<T>.
Source
public static IEnumerable<T> ToEnumerable<T>(this IEnumerator<T> enumerator)
{
while (enumerator.MoveNext())
yield return enumerator.Current;
yield break;
}
Example
IEnumerator<string> enumerator = ...;
foreach (var str in enumerator.ToEnumerable())
Console.WriteLine(str);
Author: Richard Dingwall
Submitted on: 9 dec. 2011
Language: C#
Type: System.IEnumerator<T>
Views: 7941