I’m using a enum with countries in a comboBox. All enums are in a class called Countries. Some of them has underscores like United_States_of_America. I need to remove those underscores before it shows in the comboBox?
My thought was to use Replace("_", " "), simple if it was a common string, but not so simple with a combobox! Therefore I would preciate some help to solve this? Thanks!
private void InitializeGUI()
{
// Fill comboBox with countries
cmbCountries.Items.AddRange(Enum.GetNames(typeof(Countries)));
}
Use the power of Linq 🙂
Or using a foreach: