foreach (Feature fe in features)
{
if (fileNames.Any(file => file.Contains(fe.FeatureName)))
{
fe.MatchCount = fe.MatchCount == 0 ? 1 : fe.MatchCount;
}
}
You are mutating the object at the end of the loop-variable, so you can't do that (cleanly) in pure LINQ. Just keep the loop; it'll be simpler to understand, but maybe it can be reduced a bit:
var qry = features.Where(fe => fe.MatchCount == 0 &&
fileNames.Any(file => file.Contains(fe.FeatureName));
foreach (Feature fe in qry) { fe.MatchCount == 1; }
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