/// <summary>
/// 将字典转换成name=value这种字符串格式
/// </summary>
/// <param name="dic"></param>
/// <returns></returns>
public static string DictionaryToStr(IDictionary<string,string> dic)
{
//使用排序字典
dic = new SortedDictionary<string, string>(dic);
string strTemp = string.Empty;
foreach (KeyValuePair<string, string> item in dic)
{
if (!string.IsNullOrEmpty(item.Key) && !string.IsNullOrEmpty(item.Value))
{
strTemp += item.Key + "=" + item.Value + "&";
}
}
strTemp = strTemp.TrimEnd(‘&‘);
return strTemp;
}
本文出自 “Day Day Up” 博客,请务必保留此出处http://1433189426.blog.51cto.com/8055494/1761910
原文:http://1433189426.blog.51cto.com/8055494/1761910