I often have to write APIs that include pairs of key values, when I work with this, I usually get a collection object List<KeyValuePair<string,string>>or similar type that allows me to write operations very easily.
The only drawback that I encountered is the addition of several elements to this collection, as a rule, leads to a very noisy block of code, for example
MyDictionary.Put(new KeyValuePair<string, string>("a","1"),
new KeyValuePair<string, string>("b","2"),
new KeyValuePair<string, string>("c","3"))
I would rather be able to do
MyDictionary.Put( {"a","1"}, {"b","2"}, {"c","3"})
Several times I tried to execute and always end up what C # expects exactly as the syntax for this.
source
share