How to calculating the sum of integers in one dimensional int array in C#

1 Answer

0 votes
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] arr = { 1, 2, 3, 4, 5 };

            Console.WriteLine("sum arr = " + arr.Sum());
        }

    }
}

/*
run:
 
sum arr = 15
  
*/

 



answered Feb 4, 2016 by avibootz
...