gpt4 book ai didi

c# - .GroupBy() 是否保证其分组的顺序?

转载 作者:行者123 更新时间:2023-12-02 00:13:06 26 4
gpt4 key购买 nike

假设我有一个(有序的)动物序列:

EagleElephantTarantulaTerrapinTiger

and I group by first letter:

Animals.GroupBy(animal => animal.First())

结果序列中的IGrouping元素的顺序是否与输入序列相同?

最佳答案

是的,它们将是:GroupBy (MSDN) .

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

关于c# - .GroupBy() 是否保证其分组的顺序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12377891/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com