// 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; namespace E { public class MainClass { public static void Main(string[] args) { ArrayList lst = new ArrayList(); lst.Add("240101000,1,24"); lst.Add("240101000,2,27"); lst.Add("240101000,3,24"); lst.Add("888888888,1,78"); lst.Add("888888888,2,41"); lst.Add("888888888,3,77"); int old = -1; string temp = ""; for (int i = 0; i < lst.Count; i++) { string[] parts = ((string)lst[i]).Split(",".ToCharArray()); int n1 = int.Parse(parts[0]); int n2 = int.Parse(parts[1]); int n3 = int.Parse(parts[2]); if(n1 != old) { if(temp != "") Console.WriteLine(temp); temp = n1 + "," + n3; old = n1; } else { temp = temp + "," + n3; } } if(temp != "") Console.WriteLine(temp); } } }