public static Dictionary<string, string> UrlToDictionary(this string s)
{
var dic = new Dictionary<string, string>();
if (s.Contains("&") || s.Contains("="))
{
var args = HttpUtility.ParseQueryString(s);
if (args == null || args.Count <= 0) { return dic; }
foreach (var key in args.AllKeys)
{
if (key == null) { continue; }
if (dic.ContainsKey(key))
{
dic[key] = args[key];
}
else
{
dic.Add(key, args[key]);
}
}
}
return dic;
}
C#将URL中的参数转换成字典Dictionary<string, string>
最新推荐文章于 2024-04-27 09:13:51 发布