C#获取url字符串参数值

 /// 
        /// 获取url字符串参数,返回参数值字符串
        /// 
        /// 参数名称
        /// url字符串
        /// 
        public string GetQueryString(string name,string url)
        {          
            System.Text.RegularExpressions.Regex re = new System.Text.RegularExpressions.Regex(@"(^|&)?(\w+)=([^&]+)(&|$)?", System.Text.RegularExpressions.RegexOptions.Compiled);
            System.Text.RegularExpressions.MatchCollection mc = re.Matches(url);
            foreach (System.Text.RegularExpressions.Match m in mc)
            {
                if (m.Result("$2").Equals(name))
                {
                    return m.Result("$3");
                }               
            }
            return "";
        }

你可能感兴趣的:(C#,http)