Skip to content

Instantly share code, notes, and snippets.

View panteamihai's full-sized avatar

Mihai Pantea panteamihai

  • Cluj-Napoca
View GitHub Profile
@rob-blackbourn
rob-blackbourn / BufferExtension.md
Last active September 7, 2022 16:18
A C# linq extension to buffer an enumerable into an enumerable of enumerable blocks

Bufering in linq

static void Main()
{
    foreach (var block in "The quick brown fox jumped over the lazy dog".Split(' ').Buffer(4))
        Console.WriteLine(string.Join(" ", block));
}

The code takes the sentence "The quick brown fox jumped over the lazy dog", splits it into words, buffers it into blocks of four words, then writes each block of words joined by spaces.