I have a list of objects with three integer properties. How can I get the distinct values of first integer property from my list?
This should work,
List<int> result = YourListObject.Select(o => o.FirstInteger).Distinct().ToList();
Try:
var g = collection.Select(i => i.Property1).Distinct();
Could you post some source code so that we can give you a better example?
EDIT:
In my example, I have a collection collection
which contains numerous instances of your class. I'm then selecting Property1
from each class, filtering to the distinct values of that property.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With