Método de implementación de clasificación lexicográfica y eliminación de vacíos durante el acoplamiento de terceros

     /// <summary>
    /// 生成签名,key为空时,不加入加密
    /// </summary>
public static string GetSigns(Dictionary<string, string> nativeObj, string key)
        {
    
    
            string sign = "";
            Dictionary<string, string> newobj = new Dictionary<string, string>();
            string temp = "";
            //参数的排序及去空
            var dicSort = from objDic in nativeObj where objDic.Value != "" orderby objDic.Key select objDic;
            foreach (var item in dicSort)
            {
    
    
                if (temp != "")
                    temp += "&";
                temp += item.Key + "=" + item.Value;
            }
            if (!string.IsNullOrEmpty(key))
                temp += "&key=" + key;
                return temp ;
        }

Supongo que te gusta

Origin blog.csdn.net/weixin_49543015/article/details/121682585
Recomendado
Clasificación