Accessing hard-coded data in a C# application.

Posted by haymansfield on Stack Overflow See other posts from Stack Overflow or by haymansfield
Published on 2010-06-14T13:40:51Z Indexed on 2010/06/14 13:42 UTC
Read the original article Hit count: 162

Filed under:
|
|

I'm trying to avaid hardcoding in a .net 2.0 soon to be 3.5 application.

I have a large enumneration which I wish to map 1 to 1 to a set of strings. Each enumerated value will also map to 1 of 2 values indicating an action. The existing code does this with a big switch statement but this seems ugly to me.

Is there a better way of storing and accessing the data?

I've thought about resx files but when you consider that the designer file contains just as many hardcoded values it seems a little pointless.

Is embedding an xml file in the assembly a good idea?

Is a big switch statement not as bad as it seems?

Is there a better solution?

© Stack Overflow or respective owner

Related posts about c#

Related posts about .NET