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

代码如下:

        /// 
        /// c# 参数名ascii码从小到大排序(字典序)拼接
        /// 
        /// 
        /// 
        public static string AsciiDicToStr(Dictionary 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);
        }

  

你可能感兴趣的:(c# 参数名ascii码从小到大排序(字典序)拼接)