gpt4 book ai didi

c# - 从 IGrouping 中检索所有值

转载 作者:行者123 更新时间:2023-12-02 05:35:26 25 4
gpt4 key购买 nike

我目前有:

UIEnumerable <IGrouping<PortableKey, FileInfo>> 

从这段代码:

var queryDupFiles = from file in fileList
group file by new PortableKey { Name = file.Name, Length = file.Length }
into g
where g.Count() > 1
select g;

PortableKey 的代码在哪里:

    public class PortableKey
{
public string Name { get; set; }
public long Length { get; set; }
}

基本上过滤并抓取所有重复的文件。我如何获取它以便以这种方式拥有所有 FileInfo?

List<FileInfo> list

最佳答案

您需要使用额外的 from 子句:

from f in g
select f

这转化为 .GroupBy(...).SelectMany(g => g)

关于c# - 从 IGrouping 中检索所有值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11766001/

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