Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

3
  • 3
    There needs to be more justification/description in this answer. What does AggregateObject add to KeyValuePair? Where is the "iteration," as requested in the question? Commented Dec 29, 2017 at 16:37
  • Select iterates over dictionary and allows us to work on each object. It is not as general as foreach, but I've used it a lot. Did my answer truly deserve downvote? Commented Jun 2, 2018 at 18:37
  • 1
    No, Select uses iteration to effect the result, but is not an iterator itself. The types of things that iteration (foreach) is used for--especially operations with side-effects--are outside the scope of Linq, including Select. The lambda will not run until aggregateObjectCollection is actually enumerated. If this answer is taken as a "first path" (i.e., used before a straight foreach) it encourages bad practices. Situationally, there may Linq operations that are helpful before iterating a dictionary, but that doesn't address the question as asked. Commented Jun 4, 2018 at 16:11