代码如下:
/// <summary>
/// c# 参数名ascii码从小到大排序(字典序)拼接
/// </summary>
/// <param name="dir"></param>
/// <returns></returns>
public static string AsciiDicToStr(Dictionary<string, string> dir)
{
string[] arrKeys = dir.Keys.ToArray();
Array.Sort(arrKeys, string.CompareOrdinal);
var sb = new StringBuilder();
foreach (var key in arrKeys)
{
string value = dir[key];
sb.Append(key + "=" + value + "&");
}
return sb.ToString().Substring(0, sb.ToString().Length - 1);
}