/// <summary> /// 数据字典内的key按照字典排序,常见于加密算法中 /// </summary> private static string sortKey(Dictionary<string, object> param) { StringBuilder str = new StringBuilder(); var keys = param.Keys.OrderBy(u => u).ToList(); foreach(string key in keys) { object value = param[key]; if (value != null && !string.IsNullOrWhiteSpace(value.ToString())) { str.Append(string.Format("{0}={1}&",key,value.ToString())); } } if (str.Length > 0) str = str.Remove(str.Length-1,1); return str.ToString(); }