查找数组中单词最小和最大长度的最短方法

Wah*_*eed 1 c# lambda

我有以下数组

string[] words = { "cherry", "apple", "blueberry", "banana", "mango", "orange", "pineapple" };
Run Code Online (Sandbox Code Playgroud)

我想找到MaxMin不.字母表.例如Max = 9(对于菠萝)和Min = 5(对于苹果)

这是最简单的方法.

CMS*_*CMS 13

您可以使用MinMax方法:

var min = words.Min(w=> w.Length);  // 5
var max = words.Max(w=> w.Length);  // 9
Run Code Online (Sandbox Code Playgroud)