public static NameValueCollection ParseQueryString(string url)
{
NameValueCollection cPar = new NameValueCollection();
url = url.StartsWith("?") ? url.Substring(1) : url;
string[] pairs = url.Split(new char[] { '&' });
int tmpIndex;
foreach (string pair in pairs)
{
if (string.IsNullOrEmpty(pair))
continue;
tmpIndex = pair.IndexOf('=');
if (tmpIndex == -1)
continue;
cPar.Add(pair.Substring(0, tmpIndex), pair.Substring(tmpIndex + 1));
}
return cPar;
}
C# 获取URL参数 NameValueCollection
最新推荐文章于 2022-05-04 13:50:27 发布