I want to populate a list that provides both enum values and descriptions. How do I do this in C#?
I know how to create a list of values but I also want to include the descriptions. Here's what my enums looks like:
using System.ComponentModel;
public enum BusinessCategory
{
[Description("Computers & Internet")]
ComputersInternet = 1,
[Description("Finance & Banking")]
FinanceBanking = 2,
[Description("Healthcare")]
Healthcare = 3,
[Description("Manufacturing")]
Manufacturing = 4
}
I'd like my list to look like:
[
{ 1, "Computers & Internet" },
{ 2, "Finance & Banking" },
{ 3, "Healthcare" },
{ 4, "Manufacturing" }
]