我有清单清单,想从清单中删除重复清单。数据以列表格式存储,也就是说,IEnumerable<IEnumerable<string>> tableData
如果我们将其视为表值,则父列表用于行,子列表是每一列的值。现在,我要删除所有重复的行。表A下方的值是重复的。
List<List<string>> ls = new List<List<string>>();
ls.Add(new List<string>() { "1", "A" });
ls.Add(new List<string>() { "2", "B" });
ls.Add(new List<string>() { "3", "C" });
ls.Add(new List<string>() { "4", "A" });
ls.Add(new List<string>() { "5", "A" });
ls.Add(new List<string>() { "6", "D" });
IEnumerable<IEnumerable<string>> tableData = ls;
var abc = tableData.SelectMany(p => p).Distinct(); ///not work
手术后,我想abc应该完全是tableData格式
ls.Add(new List<string>() { "1", "A" });
ls.Add(new List<string>() { "2", "B" });
ls.Add(new List<string>() { "3", "C" });
ls.Add(new List<string>() { "6", "D" });
tableData.GroupBy(q => q.Skip(1).First()).Select(q => q.First())
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句