get average number from collection
Published: 9. October 2011 | Updated: 9. October 2011License: Microsoft Public License (MS-PL)
Categories: Collections » Linq, Framework » Math
Tags: C# Linq Math
Import namespace
using System.Linq;
Code
int[] numbers = new[] { 5, 10, 30, 100 }; double avg = numbers.Average(); Console.WriteLine(avg);Console Output:
36.25
| Send us feedback about this snippet » |





