我目前有:
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
答案 0 :(得分:5)
您需要使用其他from
子句:
from f in g
select f
这转化为.GroupBy(...).SelectMany(g => g)