I’m trying to remove all reports from a list, which are not created in a certain range of calender weeks (a property of each report). Since I want to learn LINQ, I started with this:
List<Reporte> reports = ReadAllReports();
List<sbyte> importantWeeks = GetRelevantWeeks(); // e.g. 49,51,52,1,2,3
// Remove irrelevant reports (from irrelevant calender weeks) doesn't work
IEnumerable<Reporte> importantReports = from oneReport in reports where oneReport.Kalenderwoche ??INRANGE importantWeeks?? select oneReport;
Could you help me with the correct syntax for the linq statement?
Thanks for any help!
I suspect you want:
which could be written more concisely as:
Note that if
importantWeeksbecomes larger, you may want to consider usingHashSet<int>instead ofList<int>