I’ve got an enum with possible values:
public enum Language { English = 1, French = 2, German = 3 }
Now i want my class to be dynamic in the sense that it can cater for multiple values based on the enum list. So if the enum list grew i can capture all possible values.
Here’s how my initial design looks:
public class Locale { public string EnglishValue { get; set; } public string FrenchValue { get; set; } public string GermanValue { get; set; } }
But i want something that doesnt need to recompile if the enum list (or any list) grows: Is it possible to express something like:
public class Locale { public string StringValue<T> Where T : Language }
I am open to any suggestions or design patterns that can nicely deal with this problem. Thanks
Just use a Dictionary.
Whatever you do, if you change the enum, you have to recompile, but what you probably mean is ‘maintain’ the Locale class.