Mega Code Archive

 
Categories / C# Book / 04 LINQ
 

0508 Max - Projection

public void Linq86() { string[] words = { "cherry", "apple", "blueberry" }; int longestLength = words.Max(w => w.Length); Console.WriteLine("The longest word is {0} characters long.", longestLength); } Result The longest word is 9 characters long.