c# - Is there a way I can combine two separate iterator blocks to one? -
i know impossible , meaningless, trying learn.. have:
public ienumerable<ienumerable<object>> getmany() { while (somecondition) yield homecoming getfew(); } static ienumerable<object> getfew() { while (someothercondition) yield homecoming new object(); }
can combine 2 , form 1 method? can 2 different iterator blocks lie in 1 method?
edit: not asking how solve problem have @ hand. i'm trying larn new, larger question "there way 2 separate blocks can made work in 1 function"? inquire because there anonymous types , closure in c# can have new defined within method without named type or method. likewise blocks?
what you're asking anonymous iterator blocks. eric lippert blogged on subject while back. in short, said wonderful feature he'd love see, it's extraordinarily hard implement such feature, has not been added language far (and adding in future unlikely).
c# iterator refactoring ienumerable yield-return
No comments:
Post a Comment