METHOD
Enumerable.MaxBy
Returns an element with the largest key. Establish an explicit tie-breaking policy if a particular tied element is required, and handle empty inputs before selecting.
Formal Syntax & Structure
csharp syntaxcsharp
items.MaxBy(keySelector)Working Example
Example Snippetcsharp
using System;using System.Linq;Console.WriteLine(new[] { "x", "long", "abc" }.MaxBy(s => s.Length)); // long