2

我目前有:

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
4

1 回答 1

5

您需要使用附加from条款:

from f in g
select f

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

于 2012-08-01T19:18:58.433 回答