Guest User

Guest User

  • Tech Writer
  • 3
  • 2k

Trying to get the absolute sum of an int array using console

Aug 6 2018 1:45 PM
int[] array = { 4, -10, -8, 9, -2, 15, 5, 10, 4, 2 };
int<Array> b = a.ConvertAll<Array>(x => Math.Abs(x)));
foreach (int value in array)
Console.WriteLine("Abs({0}) = {1}", value, Math.Abs(value));
Console.ReadKey();
 
I'm trying to get the absolute sum of the array above, the code above i have used gives me a list and converts them to absolute numbers but i am looking for the console to output the Sum of the absolute values in the list. But i am unsure on how to tackle this problem. The anwser that i am trying to achieve from the console is 69.

Answers (1)