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?
I got this simple answer.. Use JavaScriptSerializer Class for this.
And you can simply call Serialize method with Dictionary object as argument.
Example:
var dct = new Dictionary();
var js = new JavaScriptSerializer();
dct.Add("sam","shekhar");
dct.Add("sam1","shekhar");
dct.Add("sam3","shekhar");
dct.Add("sam4","shekhar");
Console.WriteLine(js.Serialize(dct));
Output:
{"sam":"shekhar","sam1":"shekhar","sam3":"shekhar","sam4":"shekhar"}