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

java - Run spring boot application error: Cannot instantiate interface org.springframework.context.ApplicationListener -

python - pip wont install .WHL files -

Excel VBA "Microsoft Windows Common Controls 6.0 (SP6)" Location Changes -