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






uses Max to get the length of the longest 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 longestLength = words.Max(w => w.Length);

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

 








Related examples in the same category

1.Max on int array
2.Max on String array
3.Max on object list
4.Max on Object list array
5.uses Max to get the highest number in an integer array.
6.Grouped Max
7.Get the Min and max value from a query