C# LINQ — “Min”/“Max”
LINQ (Language-Integrated Query) is a set of integrated C# capabilities which allow queries against data.
Today’s Objective: Demonstrate the Min and Max methods of LINQ to get the minimum and maximum numerical values from a data collection.
The Min/Max Methods:
Simple C# LINQ methods used to identify the lowest and highest numerical values in a data collection.
Without LINQ, you may use code similar to this to find the minimum or maximum value:
But by using LINQ, you can simply write:
Like most LINQ methods, it also works for custom data types that are not numeric, but contain numeric variables: