LINQ-Max to find highest number in an array

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

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

int maxNum = numbers.Min();

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

We can also use Max
to get the length of the Longest word in an array like

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