How to get the sum of an array in c # [closed]

-1

I have an array that is {1 2 3 4 10 11} and the variable V = 6

the sum of the array should give the result = 31

thanks

    
asked by boom 16.05.2018 в 01:44
source

2 answers

2

You tried using the Sum() method from linq?

var numeros = new int[] {1, 2, 3, 4, 10, 11};
var total = numeros.Sum();
Console.WriteLine(total); // 31
    
answered by 16.05.2018 / 01:48
source
0

There is the Sum () function of the language

example of use:

int suma = arr.Sum();
    
answered by 16.05.2018 в 01:48