且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在C#中使用枚举作为数组索引

更新时间:2022-11-25 16:18:21

如果枚举项的值是连续的,方法工作得很好。但是,无论如何,您可以使用字典< DayOfTheWeek,字符串> (其性能较差)。

If the values of your enum items are contigious, the array method works pretty well. However, in any case, you could use Dictionary<DayOfTheWeek, string> (which is less performant, by the way).