码迷,mamicode.com
首页 > 编程语言 > 详细

C# 非空字段按照ASCII码从小到大排序(字典序)

时间:2016-11-16 14:04:52      阅读:1148      评论:0      收藏:0      [点我收藏+]

标签:res   add   org   color   name   value   derby   字典   nbsp   

 public static void requestPay()
        {


            Dictionary<string, string> dics = new Dictionary<string, string>();
            dics.Add("amount", amount);
            dics.Add("callback_url", callback_url);
            dics.Add("goodsname", goodsname);
            dics.Add("merchno", merchno);
            dics.Add("notify_url", notify_url);
            dics.Add("ordno", ordno);
            dics.Add("organno", organno);
            dics.Add("version", version);
            dics.Add("paytype", paytype);

            getParamSrc(dics);

        }

        public static String getParamSrc(Dictionary<string, string> paramsMap)
        {

            var vDic = (from objDic in paramsMap orderby objDic.Key ascending select objDic);
            StringBuilder str = new StringBuilder();
            foreach (KeyValuePair<string, string> kv in vDic)
            {
                string pkey = kv.Key;
                string pvalue = kv.Value;
                str.Append(pkey + "=" + pvalue + "&");
            }

            String result = str.ToString().Substring(0, str.ToString().Length - 1);
            return result;

        }

 

C# 非空字段按照ASCII码从小到大排序(字典序)

标签:res   add   org   color   name   value   derby   字典   nbsp   

原文地址:http://www.cnblogs.com/mrzhoushare/p/6068708.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!