SoFunction
Updated on 2025-03-07

C# parameters are sorted from small to large according to ASCII code (dictionary order)

When connecting with third-party payment, the third party will require the parameters to be sorted from small to large according to the ASCII code. as follows:

public static void requestPay()
 {  Dictionary<string, string> dics = new Dictionary<string, string>();
  ("amount", amount);
  ("callback_url", callback_url);
  ("goodsname", goodsname);
  ("merchno", merchno);
  ("notify_url", notify_url);
  ("ordno", ordno);
  ("organno", organno);
  ("version", version);
  ("paytype", paytype);
  getParamSrc(dics);
}
public static String getParamSrc(Dictionary<string, string> paramsMap)
{
  var vDic = (from objDic in paramsMap orderby  ascending select objDic);
  StringBuilder str = new StringBuilder();
  foreach (KeyValuePair<string, string> kv in vDic)
  {
   string pkey = ;
   string pvalue = ;
   (pkey + "=" + pvalue + "&");
  }
  String result = ().Substring(0, ().Length - 1);
  return result;
}

The above is the C# parameters introduced by the editor to you. The C# parameters are sorted from small to large according to ASCII code (dictionary order). I hope they will be helpful to everyone. If you have any questions, please leave me a message and the editor will reply to everyone in time. Thank you very much for your support for my website!