从 IEnumerable<T> 中获取不同的项目
Posted
技术标签:
【中文标题】从 IEnumerable<T> 中获取不同的项目【英文标题】:Get the distinct items from an IEnumerable<T> 【发布时间】:2010-03-17 09:16:30 【问题描述】:我有一个IEnumerable<Person>
对象。 Person
类具有 Designation
属性。我想从IEnumerable<Person>
中选择不同的Designation
值并将其分配给DropDownList。我该怎么做?
【问题讨论】:
【参考方案1】:var designations = persons.Select(p => p.Designation).Distinct();
【讨论】:
以上是关于从 IEnumerable<T> 中获取不同的项目的主要内容,如果未能解决你的问题,请参考以下文章