// 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) { List> list1 = new List>(); list1.Add(new Tuple(DateTime.Parse("22-Mar-2012 00:00:00"), 12)); list1.Add(new Tuple(DateTime.Parse("22-Mar-2012 01:00:00"), 22)); list1.Add(new Tuple(DateTime.Parse("22-Mar-2012 04:00:00"), 45)); list1.Add(new Tuple(DateTime.Parse("23-Mar-2012 01:00:00"), 0)); list1.Add(new Tuple(DateTime.Parse("23-Mar-2012 02:00:00"), 0)); list1.Add(new Tuple(DateTime.Parse("24-Mar-2012 05:00:00"), 20)); foreach(Tuple tp in list1) { Console.WriteLine(tp.Item1 + " " + tp.Item2); } List> list2 = new List>(); int ix1 = 0; for(DateTime dt = new DateTime(2012, 3, 22, 0, 0, 0); dt < new DateTime(2012, 3, 25, 0, 0, 0); dt = dt.AddHours(1)) { if(ix1 < list1.Count && dt == list1[ix1].Item1) { list2.Add(list1[ix1]); ix1++; } else { list2.Add(new Tuple(dt, 0)); } } foreach(Tuple tp in list2) { Console.WriteLine(tp.Item1 + " " + tp.Item2); } } } }