public static string DictToQueryString(Dictionary<string, string> data)
{
string querystring = "";
foreach (string key, string val in data)
querystring += key + "=" + val + "&";
return querystring;
}
How i foreach?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Your “code” would have an extraneous
"&"on the end. Do you want this? It’s likely that you don’t want this but please correct if you do. Assuming not, the simplest approach is to letString.Joindo its job:In C# 4.0 the call to
ToArraywill be obviated.