I have a Dictionary<string, List<string>>
I want to do a check that all Keys in the dictionary have at least 1 item in its corresponding list
Try the following
bool allPopulated = map.All(p => p.Value != null && p.Value.Count > 0);
You can use the Enumerable.All
extension method (part of the LINQ extension methods) for this.
bool allPopulated = yourDictionary.All(p => p.Value != null && p.Value.Count > 0);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With