C# 参数按照ASCII码从小到大排序(字典序)
作者:涛MR 时间:2023-03-14 22:14:11
在对接第三方支付的时候,第三方会要求参数按照ASCII码从小到大排序。如下:
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码从小到大排序(字典序)网站的支持!
来源:http://www.cnblogs.com/mrzhoushare/p/6068708.html
标签:c#,ascii码,排序
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
使用Spring Cloud Feign作为HTTP客户端调用远程HTTP服务的方法(推荐)
2022-11-09 11:40:37
Java之InputStreamReader类的实现
2023-09-03 01:28:17
Android用SharedPreferences实现登录注册注销功能
2023-03-24 21:50:10
![](https://img.aspxhome.com/file/2023/0/137140_0s.jpg)
基于Android在布局中动态添加view的两种方法(总结)
2023-08-29 20:31:36
IDEA连接Mysql数据库的详细图文教程
2023-10-09 09:51:24
![](https://img.aspxhome.com/file/2023/5/58605_0s.png)
Android中使用TextView实现文字跑马灯效果
2023-07-28 11:07:33
![](https://img.aspxhome.com/file/2023/9/84729_0s.gif)
springmvc图片上传及json数据转换过程详解
2022-02-25 17:11:14
![](https://img.aspxhome.com/file/2023/7/74927_0s.png)
java实现KFC点餐小程序
2022-12-11 21:06:51
![](https://img.aspxhome.com/file/2023/7/87137_0s.png)
java实现两个对象之间传值及简单的封装
2022-03-11 13:53:18
![](https://img.aspxhome.com/file/2023/3/132083_0s.jpg)
C#实现的Win32控制台线程计时器功能示例
2022-12-19 20:29:20
浅谈Spring的两种事务定义方式
2023-10-11 22:52:59
C#语法新特性之元组实例详解
2022-09-20 03:05:53
C#微信公众号开发之服务器配置
2023-03-12 15:02:50
![](https://img.aspxhome.com/file/2023/0/100170_0s.png)
通过Android trace文件分析死锁ANR实例过程
2023-06-11 04:58:03
![](https://img.aspxhome.com/file/2023/9/137549_0s.gif)
Java实现验证码的产生和验证
2022-10-30 22:41:39
Jenkins一键打包部署SpringBoot应用的方法步骤
2021-10-31 18:00:53
![](https://img.aspxhome.com/file/2023/9/132099_0s.jpg)
Spring boot随机端口你都不会还怎么动态扩容
2021-09-29 10:10:14
![](https://img.aspxhome.com/file/2023/7/69727_0s.png)
C#如何使用Task执行异步操作
2023-01-12 03:34:41
java读取word-excel-ppt文件代码
2022-07-06 14:20:46
Netty分布式NioEventLoop任务队列执行源码分析
2022-10-08 04:07:19