开发者

Multiple arrays count comparison C#

开发者 https://www.devze.com 2023-03-18 07:18 出处:网络
What is best way to return the count of the smallest/largest array in C# 4.0? preferably using Lambda expressions.

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消