Multiple arrays count comparison C#
What is best way to return the count of the smallest/largest array in C# 4.0? preferably using Lambda expressions.
I'm looking for a way to return the count of the smallest array within a list of arrays which would usually contain 5-10 elements. I could go for the usual foreach array > get count > if larger > override > next.. etc. but was hoping for a one-line solu开发者_如何学Gotion using LINQ/Lambda.
Something like this?
var min = arrays.Min(x => x.Length);
That will find the length of each array, and return the minimum length. If that's not what you're after, please clarify your question with an example.
精彩评论