METHOD
Enumerable.MinBy
Returns an element with the smallest key, not the key itself. Define an explicit empty-input policy; a nonnullable value-type source throws on empty, while a reference or nullable source can return null.
Formal Syntax & Structure
csharp syntaxcsharp
items.MinBy(keySelector)Working Example
Example Snippetcsharp
using System;using System.Linq;Console.WriteLine(new[] { "long", "x", "abc" }.MinBy(s => s.Length)); // x