Using Min to get the length of the shortest word in a string array. : Min « LINQ « C# / CSharp Tutorial






using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class MainClass {
    public static void Main() {
        string[] words = { "cherry", "apple", "blueberry" };

        int shortestWord = words.Min(w => w.Length);

        Console.WriteLine("The shortest word is {0} characters long.", shortestWord);
    }
}








22.55.Min
22.55.1.First Min Prototype
22.55.2.Min with string value
22.55.3.Min with object property
22.55.4.Min with string property value
22.55.5.Using Min to get the lowest number in an integer array.
22.55.6.Using Min to get the length of the shortest word in a string array.
22.55.7.Grouped Min
22.55.8.Numeric Aggregates: Min