tags:

views:

52

answers:

2

I have an IEnumerable< Person> object. The Person class has a Designation proeprty.

I want to select distinct Designation values from IEnumerable< Person> and assign that to a DropDownList. How can I do it?

+8  A: 
var designations = persons.Select(p => p.Designation).Distinct();
Anton Gogolev
A: 
  • Get every item
  • Remove duplicates
  • Add them to drop down list.

Or:

  • Get item by item
  • Check whethe ralready in list
  • If not, add.

Basic programming.

TomTom
Bad answer. Basic programming is reading the API first and not re-inventing the wheel.
Joe