Convert List> into List in C#

后端 未结 3 639
醉梦人生
醉梦人生 2020-12-10 11:08

I have a List>. I would like to convert it into a List where each int is unique. I was wondering if anyone had a

3条回答
  •  被撕碎了的回忆
    2020-12-10 11:38

    How about:

    HashSet set = new HashSet();
    foreach (List list in listOfLists)
    {
        set.UnionWith(list);
    }
    return set.ToList();
    

提交回复
热议问题