Find the Greatest and Lowest number from a series of number using Anonymous Type in C#.

Rajnilari2015
Posted by Rajnilari2015 under C# category on | Points: 40 | Views : 1015
The following example will do so

var numberCollection = new List<int>() { 14, 25, 23, 64, 4, 35, 26, 19, 100 };

// By using the max, min function of the generic collection
//Also observe the usage of Anonymous Type in C#
var result = new { GreatestNumber = intList.Max(), LowestNumber = intList.Min() };

Console.WriteLine("Max= {0} Min={1}",result.GreatestNumber,result.LowestNumber);


Output
-------

Max= 100   Min=4

Comments or Responses

Login to post response