C#将字典转换成name=value这种字符串格式
/// <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;
}
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。