c# - How foreach loop works? -
this question has answer here:
imongocollection<jobinforecord> records = ... foreach (var record in records.find(query).tolistasync().result) {...} is true foreach iteration compute .result value again , again?
no, it's going evaluate records.find(query).tolistasync().result once , call getenumerator on result. each loop going call movenext on returned "enumerator" , set record current property of "enumerator" loop breaking when movenext returns false.
Comments
Post a Comment