Mngaro Mwazenje

Mngaro Mwazenje

  • NA
  • 80
  • 13.1k

return the sum of the numbers in the parameter list.

Feb 18 2020 5:24 AM
Create the method public static int Sum(List<int> numbers) in the exercise template. The method is to return the sum of the numbers in the parameter list.
  1. List<int> numbers = new List<int>();  
  2. numbers.Add(3);  
  3. numbers.Add(2);  
  4. numbers.Add(6);  
  5. numbers.Add(-1);  
  6. Console.WriteLine(Sum(numbers));  
  7. numbers.Add(5); numbers.Add(1);  
  8. Console.WriteLine(Sum(numbers));  

Answers (11)