“Unzip” IEnumerable dynamically in C# or best alternative
问题 Lets assume you have a function that returns a lazily-enumerated object: struct AnimalCount { int Chickens; int Goats; } IEnumerable<AnimalCount> FarmsInEachPen() { .... yield new AnimalCount(x, y); .... } You also have two functions that consume two separate IEnumerable s, for example: ConsumeChicken(IEnumerable<int>); ConsumeGoat(IEnumerable<int>); How can you call ConsumeChicken and ConsumeGoat without a) converting FarmsInEachPen() ToList() beforehand because it might have two zillion