Skip to content

Instantly share code, notes, and snippets.

@djeikyb
Created July 9, 2021 19:07
Show Gist options
  • Save djeikyb/c51e229f7cc12691ac1c6c5de751f54e to your computer and use it in GitHub Desktop.
Save djeikyb/c51e229f7cc12691ac1c6c5de751f54e to your computer and use it in GitHub Desktop.
private async IAsyncEnumerable<MemoryStream> YieldStreams(params byte[][] bs)
{
// The compiler turns async + yield return type T into the
// desired return type of IAsyncEnumerable<T>. But we don't
// actually have any async code, just need the type. Soooo
await Task.CompletedTask; // hack to evade compiler warning
foreach (var b in bs) yield return new MemoryStream(b);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment