Reputation: 280
I have the following structure:
class Attribute
{
List<Value> values;
}
List<Attribute> attributes;
I need to get the Count of the longest List<Value>
from the list of attributes.
Is there a simple solution using Linq?
I already tried two nested loops, which is not very performant.
Upvotes: 0
Views: 1753
Reputation: 148110
You can use Enumerable.Max to get the list with Maximum size using the Count
attribute.
var max = attributes.Max(lst=>lst.values.Count);
Upvotes: 1