// Collection of code snippets by Arne Vajhøj // (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) using System; using System.Collections.Specialized; class MainClass { public static NameValueCollection Parse(string s) { NameValueCollection res = new NameValueCollection(); string s2 = s.Split("?".ToCharArray())[1]; string[] parts = s2.Split("=&".ToCharArray()); for(int i = 0; i < parts.Length/2; i++) { res.Add(parts[2*i], parts[2*i+1]); } return res; } public static void Main(string[] args) { NameValueCollection col = Parse("http://minserver.dk/test.asp?var1=hej&var2=du"); for(int i = 0; i < col.Count; i++) { Console.WriteLine(col.GetKey(i) + " = " + col.GetValues(i)[0]); } } }