c# 参数名ascii码从小到大排序(字典序)拼接

代码如下:

        /// <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);
}

  

上一篇:在阿里云 ECS 搭建 nginx https nodejs 环境 (一、 nginx)


下一篇:函数,lambda函数,递归函数,内置函数(map,filter),装饰器