.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Sandeep Singh
Melody Anderson
Eminent IT

Home >> Code Snippets >> Generics >> Post New Resource Bookmark and Share   

 Subscribe to Code Snippets

Get Max, Min, Sum, Avg using Generic List

Posted By:Syed Shakeer Hussain       Posted Date: December 17, 2011    Points: 40    Category: Generics    URL: http://www.dotnetspark.com  

Following code helps you to get MAX, MIN, SUM, AVG value with Generic List elements

List li = new List { 1, 2, 3 };
Console.WriteLine("\n Maximum value=" + li.Max());
Console.WriteLine("\n Sum of Value=" + li.Sum()+"\n");
Console.WriteLine("\n Minimum Value=" + li.Min() + "\n");
Console.WriteLine("\n Average=" + li.Average() + "\n");


Maximum value=3

Sum of Value=6

Minimum Value=1



Further Readings:


No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More code samples in C#, ASP.Net, Vb.Net and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend