c# - 将 IEnumerable<IGrouping<,>> 转换为数组

标签 c# linq

有没有一种简单的方法可以将以下代码中的 remaining 转换为一维数组。

var groups = data.OrderBy(d => d.Time).GroupBy(d => d.Period);
var first = groups.First().ToArray();
var remaining = groups.Skip(1).??

最佳答案

var remaining = groups.Skip(1).SelectMany(g=>g).ToArray();

关于c# - 将 IEnumerable<IGrouping<,>> 转换为数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19591194/

相关文章:

c# - HRESULT 怎么会出现在 MIDL 文件中?

c# - 是否有在 C# 中重载赋值运算符的解决方法?

C# 类型推断 : fails where it shouldn't?

c# - 为什么我会收到 System.OutOfMemoryException

c# - 正则表达式 - 匹配一个字符串,但只匹配下一个单词不是 'x' 的地方

c# - cmake build x64 使用安装的任何 visual studio 版本

c# - AutoMapper 投影中的 Lambda 表达式错误

c# - 使用 linq 连接两个表,并填充它们的字典

c# - 自定义 Linq 扩展的性能差异/改进

c# - 层次结构数据的 LINQ 递归