参数名ASCII码从小到大排序(字典序)

 /// 
        /// Hashtable字典排序
        /// 
        /// 
        /// 
        /// 
        public static string formatParameters(Hashtable parameters, Boolean encode)
        {
            StringBuilder sb = new StringBuilder();
            ArrayList akeys = new ArrayList(parameters.Keys);
            akeys.Sort();
            foreach (string k in akeys)
            {
                string v = (string)parameters[k];//防止参数不是字符串
                sb.Append(k.ToLower() + "=" + v + "&");
            }
            //去掉最后一个&
            if (sb.Length > 0)
            {
                sb.Remove(sb.Length - 1, 1);
            }
            return sb.ToString();
        }

  

转载于:https://www.cnblogs.com/Gold-fangjin/p/6038869.html

你可能感兴趣的:(参数名ASCII码从小到大排序(字典序))