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

Popular posts from this blog

How to check data type in C++? -

javascript - Is getTimezoneOffset() stable during daylight saving transition? -

sql server - SQL Query returns one result, does not return 0 or NULL result -