Enums or Tables?

后端 未结 9 1080
天命终不由人
天命终不由人 2021-02-06 08:38

I am making this a community wiki, as I would appreciate people\'s approach and not necessarily an answer.

I am in the situation where I have a lot of lookup type data

9条回答
  •  佛祖请我去吃肉
    2021-02-06 09:03

    First make sure this data is really static. If anything changes, you will have to recompile and redeploy.

    If the data is really static, I would go the enum route. You could create a YearlySalaryEnum holding all the values. For string representation I would use a Dictionary with string values and the YearlySalaryEnum as Key. The dictionary can be hold as a static instance in a static class. Usage would be along the lines of (C#):

    string highSalary = StaticValues.Salaries[YearlySalaryEnum.High];
    

提交回复
热议问题