// 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.Generic; using System.Linq; namespace E { public class Program { public static void Main(string[] args) { string s = "malnr;instnr;group;22958;336654;6"; string[] a = s.Split(';'); Dictionary d = a.Take(a.Length/2).Zip(a.Skip(a.Length/2), (s1,s2) => Tuple.Create(s1, int.Parse(s2))).ToDictionary(t => t.Item1, t => t.Item2); foreach(KeyValuePair kvp in d) { Console.WriteLine("{0} : {1}", kvp.Key, kvp.Value); } } } }