I wanted to fill WinForms Combobox with enum values, yet when I tried to do it with Linq, no items were added to the Combobox. However, the foreach variant works just fine.
My Linq:
Enum.GetNames(typeof(AgeCategory))
.Select(x => cbCategory.Items.Add(x));
My foreach:
foreach (var category in Enum.GetNames(typeof(AgeCategory)))
{
cbCategory.Items.Add(category);
}
Also, if you know about a better way to do this, I'm open to different solutions.