I have List<MyObject> listObjects where I would like a unique list of MyObject.CategoryName as List<string>.
I have the following linq so far.
var categoryNames = from element in listObjects
orderby element.CategoryName
group element by element.CategoryName;
However, var categoryNames is a IEnumerable<IGrouping<string, MyObject>>.
How can I get the list as a List<string>?
thank you.
In words: “Grab only the category names, and then ignore duplicates, and put them into a list.”