我目前有:
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/