C# 一段高效拆分url请求地址中参数的代码

版权声明:本博所有原创文章,欢迎转载但不得作为商业用途,转载请注明出处。 https://blog.csdn.net/qq_16587307/article/details/84025307
        private static Dictionary<string, string> GetRequestParameters(string row)
        {
            if (string.IsNullOrEmpty(row)) return null;
            var kvs = Regex.Split(row, "&");
            if (kvs == null || kvs.Count() <= 0) return null;

            return kvs.ToDictionary(e => Regex.Split(e, "=")[0], e => Regex.Split(e, "=")[1]);
        }
Action=00&cmdType=01&tag=0001

代码可以对上面的url地址拆分成Dictionary, key为等号左边的值,value为等号右边的值。

猜你喜欢

转载自blog.csdn.net/qq_16587307/article/details/84025307