What is the most efficient way to create a constant (never changes at runtime) mapping of strings to ints?
I\'ve tried us
If using 4.5+ Framework I would use ReadOnlyDictionary (also ReadOnly Collection for lists) to do readonly mappings/constants. It's implemented in the following way.
static class SomeClass
{
static readonly ReadOnlyDictionary SOME_MAPPING
= new ReadOnlyDictionary(
new Dictionary()
{
{ "One", 1 },
{ "Two", 2 }
}
)
}