Linq to Objects: does GroupBy preserve order of elements?

前端 未结 1 527
感情败类
感情败类 2020-12-03 02:31

Does Enumerable.GroupBy from LINQ to Objects preserve order of elements in the groups?

1条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-03 03:05

    Found answer on MSDN: Yes.

    The IGrouping objects are yielded in an order based on the order of the elements in source that produced the first key of each IGrouping. Elements in a grouping are yielded in the order they appear in source.

    0 讨论(0)
提交回复
热议问题