I want to consume some files and I need to know where to put each of the data. One column is called "Category".
I can have many categories and I want to build an enum to support them.
public enum GasKeyWords
{
Gas,
Fuel,
Gas&Fuel
}
public enum EducationKeyWord
{
Education,
Books&Supplies,
StudentLoan
Tuition
}
I am thinking of something like this
foreach(var r in records)
{
Categories.GasKeyWords GasKeyWords;
bool valid = Enum.TryParse<Categories.GasKeyWords>(r, out GasKeyWords);
if (valid)
{
// add to group
}
}
and keep using TryParse till I find a group it can parse too. I am not sure if this is the best way to do it(I am always open to better ideas).
However the problem I facing right now is that I can't use "&" in enum names. I don't have control of these category names so I can't change it.