Min
The Min
method is the opposite of the Max operator. It finds and returns the smallest, based on the type of array or list.
Basic example
Live example: https://dotnetfiddle.net/omUOQX
var scores = new[] { 2, 4, 6, 8, 10 };
var min = scores.Min();
// output: 2
Min with objects
You can also apply the Min operation of a list of complex objects if need be.
Live example: https://dotnetfiddle.net/0xGnDb
var people = new[]
{
new
{
Name = "Vernon",
Age = 21
},
new
{
Name = "Carrie",
Age = 24
},
new
{
Name = "Joanna",
Age = 20
}
};
var minAge = people.Min(arg => arg.Age);
// output: 20