Return to Snippet

Revision: 23003
at January 27, 2010 12:28 by streamt


Initial Code
Dictionary<String, String> result = new Dictionary<string, string>();
String urlString = "http://www.jwize.com?param1=valu1&param2=value2";

var query = from match in urlString.Split('?').Where(m => m.Contains('='))
                .SelectMany(pr => pr.Split('&'))
            where match.Contains('=')
            select new KeyValuePair<string, String>(
                match.Split('=')[0],
                match.Split('=')[1]);
query.ToList().ForEach(kvp => result.Add(kvp.Key, kvp.Value));

Initial URL

                                

Initial Description

                                

Initial Title
Get URL Parameters using LINQ

Initial Tags

                                

Initial Language
C#