实际清单中的自定义清单(无重复) [英] Custom List from actual List (without duplicates)

查看:66
本文介绍了实际清单中的自定义清单(无重复)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个列表,如下所示:

I have a list , something like this:

list1<person>={elem1, elem2, elem3...}
and elem1 = name1, age1, haircolor1
    elem2 = name2, age2, haircolor2
    elem3 = name3, age3, haircolor3 ...





该列表包含重复项,意思是elem1标签可以与elem2标签相同,但内容(名称,年龄,发色)不同



我想要制作自定义列表:





The list contains duplicates, meaning elem1 label can be the same as elem2 label, but the contents (name, age, haircolor) are different

I want to make a custom list:

list2 = { elem1 = name1 age1 haircolor1
                  name3 age3 haircolor3

          elem2 = name2, age2, haircolor2
          elem4 = name4, age4, haircolor4
                  name6, age6, haircolor6
                  name7, age7, haircolor7 } 





谢谢!



Thank you!

推荐答案

list1.GroupBy(p => p.YourElement)

希望它适合你
list1.GroupBy(p=>p.YourElement)
Hope it will work for you


这篇关于实际清单中的自定义清单(无重复)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆