Currently using an enum for a list of filenames in an application for the ability to use intellisense and to make sure the filename is one of the existing files (the enum prevents typos and having to remember each filename verbatim). There are currently 107 files in the enum. In order to get an audio file name the enum value ToString() method is used.
Now there is a situation where there needs to be some filenames added based on the result of a database call. This isn't possible with an enum and will require a lot of application restructuring to implement (changing all methods that take an enum to take a string).
What should have been done in the first place or is an enum the best option for this use case?
I'm not quite sure of the use case, but one consideration is resource files. You would get intellisense, and the added bonus of being able to change the file names per localisation.
See here for an example.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With