I found the default implemtation of ToString in the dictionary is not what I want. I would like to have {key=value, ***}.
Any handy way to get it?
If you just want to serialize for debugging purposes, the shorter way is to use String.Join:
var asString = string.Join(Environment.NewLine, dictionary);
This works because IDictionary implements IEnumerable.
Console.WriteLine(string.Join(Environment.NewLine, new Dictionary {
{"key1", "value1"},
{"key2", "value2"},
{"key3", "value3"},
}));
/*
[key1, value1]
[key2, value2]
[key3, value3]
*/