This is a pretty trivial question, but I'm curious to hear the opinions of people on it.
If I have a dictionary that can be accessed through properties, which of these formats do you prefer for the property?
[DefaultValue("myValue")]
public string FirstProperty {
get {
return Dictionary["myKey"];
}
set {
Dictionary["myKey"] = value;
}
This is probably the typical way to do this. It is quite effective, easy to understand, etc. The only drawback is a longer or more complex key, which could seal or change only one instance or something else, which will lead me to this:
[DefaultValue("myValue")]
private const string DICT_MYKEY = "myKey"
public string SecondProperty {
get {
return Dictionary[DICT_MYKEY];
}
set {
Dictionary[DICT_MYKEY] = value;
}
, , , , "Code Complete". , , /// [DefaultValue()] , .
, , ? - ?