C#C
C#4y ago
Natty

❔ LINQ Question - Thought I solved it...

I have a list of dates in month/day/year format, and I've created a hashset that holds ending quarter months:
var allDates = List(); // "1/1/2017, 5/23/2018, etc"
var quarterEndMonths = new HashSet<string> { "3", "6", "9", "12" };

My goal is to have a bool that checks if the allDates only contains Quarter months (3,6,9,12). Here's what I have so far:
bool onlyContainsQuarters = allDates.Any(x => quarterEndMonths.Any(prefix => x.StartsWith(prefix)));
Was this page helpful?