Distinct in linq?

前端 未结 5 1267
我寻月下人不归
我寻月下人不归 2020-12-31 20:07

I am wondering how can I achieve this?

I want to get only distinct names from a collection of objects

MyObject a = new Object();
a.Name = \'One\';
a.         


        
5条回答
  •  离开以前
    2020-12-31 20:19

    If you just want back distinct names, you can use:

    myCollection.Select(x => x.Name).Distinct().ToList();
    

提交回复
热议问题