uses Min to get the length of the shortest word in a string array. : Min « LINQ « C# / C Sharp






uses Min to get the length of the shortest word in a string array.

 
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);
    }
}

 








Related examples in the same category

1.First Min Prototype
2.Min with string value
3.Min with object property
4.Min with string property value
5.use Min to get the lowest number in an integer array.
6.Grouped Min