using System.Collections.Generic;
public static void Main()
var source = "The quick brown fox jumps over the lazy dog.";
foreach(var chars in source.Chunk(5))
Console.WriteLine(new string(chars.ToArray()));
public static class ChunkHelper {
public static IEnumerable<IEnumerable<T>> Chunk<T>(this IEnumerable<T> values, int chunkSize)
var e = values.GetEnumerator();
yield return innerChunk(e, chunkSize);
private static IEnumerable<T> innerChunk<T>(IEnumerator<T> e, int chunkSize)
while(i++ < chunkSize && e.MoveNext())