How to calculate the average of all elements in int array using Linq in C#

1 Answer

0 votes
using System;
using System.Linq;

namespace ConsoleApplication_C_Sharp
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] array = { 3, 12, 9, 5, 1 };

            Console.WriteLine(array.Average());
        }
    }
}


/*
run:
     
6
 
*/

 



answered Feb 21, 2017 by avibootz

Related questions

1 answer 255 views
1 answer 295 views
1 answer 286 views
1 answer 196 views
...