我有以下日期列表:
List<Datetime> listOfDates = new List<DateTIme>();
listofDates.add(new DateTime(2012,01,04));
listofDates.add(new DateTime(2012,01,05));
listofDates.add(new DateTime(2012,01,06));
..
listofDates.add(new DateTime(2012,01,31));
listofDates.add(new DateTime(2012,02,01));
..
listofDates.add(new DateTime(2012,02,28));
listofDates.add(new DateTime(2012,03,01));
..
listofDates.add(new DateTime(2012,03,16));
我需要按月份范围过滤上述列表,如下所示:
var filterdListByMonth = listofDates.Where(x.DateTime.Month => 1 and x.DateTime.Month <=2).ToList();
但这似乎并没有返回正确的结果。有人可以帮忙吗?