以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- .net代码转换为VB (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=180848) |
-- 作者:otterlike -- 发布时间:2022/10/18 10:30:00 -- .net代码转换为VB 各位老师好!以下.net代码请问该如何转换为VB,感激不尽! static String Send(String apiName, String apiVersion, Dictionary<String, String> dict) { HttpWebRequest request = WebRequest.Create(URL) as HttpWebRequest; request.Method = "POST"; request.ContentType = "application/json";
// 设置请求参数 dict.Add("_api_access_key", AK); dict.Add("_api_name", apiName); dict.Add("_api_version", apiVersion);
// 对参数进行字典序排序 List<KeyValuePair<string, string>> lst = new List<KeyValuePair<string, string>>(dict); lst.Sort(delegate (KeyValuePair<string, string> source, KeyValuePair<string, string> target) { return source.Key.CompareTo(target.Key); }); StringBuilder signBuilder = new StringBuilder(); StringBuilder paramBuilder = new StringBuilder();
// 拼写请求字串 foreach (KeyValuePair<string, string> item in lst) { string key = item.Key; string value = item.Value; // 签名字串 signBuilder.Append("&").Append(key).Append("=").Append(value);
//value = Server if (HEADERS.Contains(key)) { request.Headers[key] = value; } else { paramBuilder.Append("&").Append(key).Append("=").Append(value); } }
if(paramBuilder.Length>1) paramBuilder.Remove(0, 1); signBuilder.Remove(0, 1);
string signStr = signBuilder.ToString();
}
|
-- 作者:有点蓝 -- 发布时间:2022/10/18 10:49:00 -- 到这转换:https://converter.telerik.com/ |