// 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("21-Mar-2012 00:00:00"), 0)); 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 = list1.Where(tp => tp.Item2 == 0).Where(tp => tp.Item1 >= new DateTime(2012, 3, 22) && tp.Item1 < new DateTime(2012, 3, 26)).ToList(); foreach(Tuple tp in list2) { Console.WriteLine(tp.Item1 + " " + tp.Item2); } } } }