c# - Add Duplicates keys to NameValueCollection -
i have read namevaluecollection allows duplicate keys added, not seem case when try use it.
my code
using (var wb = new webclient()) { var data = new namevaluecollection(); var sourcedata = (list<dictionary<string, object>>)dic["mapdata"]; var countsource = sourcedata.count; foreach (var item in (list<dictionary<string, object>>)dic["mapdata"]) { data.add("pp", item["latitude"].tostring() + "," + item["longitude"].tostring()); } var datacount = data.count; var response = wb.uploadvalues(@"http://dev.virtualearth.net/rest/v1/imagery/map/road/?maparea=" + swlat.tostring() + "," + swlong + "," + nelat + "," + nelong + "&mapsize=800,600&key=" + key, "post", data); return this.largejson(new { imagedata = createbase64image(response) }); }
what observing
my sourcedata contains 36 items
i iterating through sourcedata , adding items namevaluecollection data , add items same key "pp"
i expecting have 36 items in data namevaluecollection, getting 1 , of values appended same key.
what missing ?
this expected behaviour - see the documentation:
if specified key exists in target namevaluecollection instance, specified value added existing comma-separated list of values in form "value1,value2,value3". values associated same key in target namevaluecollection instance.
Comments
Post a Comment