Coming from a javascript background, collections like dictionaries are often implemented as objects because their properties can be referenced by association:
// js example
var myDict = {
key1 : "value1",
key2 : "value2"
};
myDict.key1; // "value1"
myDict["key1"]; // "value1"
However, in C# it seems we have to choose between static singleton classes and generic dictionaries for each effect. While I like that classes are strongly typed and give intellisense support, Dictionary methods offer flexibility I’m hesitant to give up. Are there performance considerations so great in C# that I should choose one over the other?
In fact, a class would be several orders of magnitude faster than a
Dictionary. If you feel it’s more convenient, that’s even better 🙂 So if you’re able to make classes for it, do so. If the objects you represent really should be classes (i.e. are fundamentally objects and not key/value pairs) then all the more reason.