C # does not allow lambda functions to represent iterator blocks (for example, there is no "return return" allowed inside a lambda function). If I wanted to create a lazy enumeration that would bring all disks during enumeration, for example, I would like to do something like
IEnumerable<DriveInfo> drives = {foreach (var drive in DriveInfo.GetDrives()) yield return drive;};
This took some time, but I figured it out as a way to get this functionality:
var drives = Enumerable.Range(0, 1).SelectMany(_ => DriveInfo.GetDrives());
Is there a more idiomatic way?
source share