Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What can a person use instead of enum for an intellisense aware collection of strings?

Tags:

c#

.net

enums

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?

like image 809
Nathan Hillyer Avatar asked Feb 18 '23 15:02

Nathan Hillyer


1 Answers

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.

like image 115
devdigital Avatar answered Feb 21 '23 17:02

devdigital