fork download
  1. using System;
  2.  
  3. class Pruebaparams
  4. {
  5. static int Suma(params int[] operandos)
  6. {
  7. int suma = 0;
  8. for (int i = 0; i < operandos.Length; i++)
  9. {
  10. suma += operandos[i]; // acumulador de los operandos
  11. }
  12.  
  13. return suma;
  14. }
  15.  
  16. static void Main()
  17. {
  18. int total = Suma(1, 2, 3, 4, 5);
  19. Console.WriteLine(total); // 15
  20. total = Suma(11, 19, 29);
  21. Console.WriteLine(total); // 59
  22. }
  23. }
Success #stdin #stdout 0.03s 33904KB
stdin
Standard input is empty
stdout
15
59