Selector type | Result type |
---|---|
decimal | decimal |
int, long, float, double | double |
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
class Program
{
static void Main()
{
decimal[] numbers = { 3, 4, 8 };
decimal average = numbers.Average(); // 5 (mean value)
Console.WriteLine(average);
double avg = new int[] { 3, 4 }.Average(); // 3.5
Console.WriteLine(avg);
}
}
The output:
5
3.5
java2s.com | Contact Us | Privacy Policy |
Copyright 2009 - 12 Demo Source and Support. All rights reserved. |
All other trademarks are property of their respective owners. |