如何将“ Var”数据类型中的项目显示到ListView中?

时间:2019-04-20 06:24:22

标签: c#

如何将这种Var数据类型(myFilesList)中的项目添加到listView1中?

        var myFilesList = allFiles.Select(f =>
        {
            using (var fs = new FileStream(f, FileMode.Open, FileAccess.Read))
            {
                return new
                {
                    FileName = f,
                    FileHash = BitConverter.ToString(SHA1.Create().ComputeHash(fs))
                };
            }
        }).GroupBy(f => f.FileHash).Select(g => new { FileHash = g.Key, Files = g.Select(z => z.FileName).ToList() })
        .SelectMany(f => f.Files.Skip(1)).ToList();

1 个答案:

答案 0 :(得分:0)

尝试

foreach (var item in myFilesList )
{
ListViewItem item1 = new ListViewItem(item.your desired property);
ListView1.Items.AddRange(item1);
}

希望有帮助