LINQ-Use Min to get the lowest number in an array.

This is the function for finding lowest number in Array using LINQ.

public void FindMinNumber()
{
int[] numbers = { 10,30,55,2,8,9,66,120,3,4 };

int minNum = numbers.Min();

Console.WriteLine("The minimum number is {0}.", minNum);
}

We can also use Min
to get the length of the shortest word in an array like

public void FindMinWordLength() { string[] words = { "India", "America", "England","Iraq" }; int shortestWordLength = words.Min(w => w.Length); Console.WriteLine("The shortest word is {0} characters long.", shortestWordLength); }
Ebook Download
View all
Learn
View all