【发布时间】:2022-01-14 14:16:37
【问题描述】:
我有一个班级列表:
class GroupAssets
{
public string Name { get; set; }
public List<string> Assets { get; set; }
}
List<GroupAssets> GroupList2 = new List<GroupAssets>{
new GroupAssets { Name="Group1", Assets = new List<string>{ "A","B","C","D" }},
new GroupAssets { Name="Group1", Assets = new List<string>{ "A","B","E","F" }},
new GroupAssets { Name="Group3", Assets = new List<string>{ "A","B","H","G" }},
new GroupAssets { Name="Group4", Assets = new List<string>{ "A","I","C","J" }}
};
我想删除重复项并得到以下结果:
Group1 => D
Group2 => E,F
Group3 => H,G
Group4 => I,J
Duplicate => A,B,C
感谢您的帮助
【问题讨论】:
-
所有发布的只是程序描述,但这并不能告诉我们您遇到了什么问题。你尝试过什么,遇到过什么烦恼?请edit您的帖子包含valid question,我们可以回答。提醒:确保您知道on-topic 是什么;要求我们为您编写程序、建议和外部链接都是题外话。
-
所以我想你的列表是新的 List
{ "A","B","C","D" }?而你有 group2 而不是 group1?你能纠正你的错误吗
标签: c# list linq duplicates