CalculaSomaNumerosInteiros

CSharp · Console

/Program.cs

using System;
using System.Linq;
					
public class Program
{
	public static void Main()
	{
		    int[] numeros = { 1, 4, 28, 15, 65, 70, 87, 44 };
            long soma = CalculaSomaNumerosPares(numeros);
            Console.WriteLine("A soma dos números pares é : {0}", soma);
            Console.ReadLine();
	}
	
    static long CalculaSomaNumerosPares(int[] numerosInteiros)
    {
            return (from i in numerosInteiros where i % 2 == 0 select (long)i).Sum();
	}
}
;