How does Func Work?

后端 未结 3 1212
悲哀的现实
悲哀的现实 2021-02-05 08:58

I am creating a Distinct extension method where I can pass in the criteria like the following.

persons.Distinct(p => p.Name); 

I got the co

3条回答
  •  遇见更好的自我
    2021-02-05 09:32

    You are getting back the distinct People, under the assumption that two People are the same if they have the same name

    If you want a distinct set of names, you can use this:

    IEnumerable names = persons.Select(p => p.Name).Distinct();
    

提交回复
热议问题