Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Pruebaparams
- {
- static int Suma(params int[] operandos)
- {
- int suma = 0;
- for (int i = 0; i < operandos.Length; i++)
- {
- suma += operandos[i]; // acumulador de los operandos
- }
- return suma;
- }
- static void Main()
- {
- int total = Suma(1, 2, 3, 4, 5);
- Console.WriteLine(total); // 15
- total = Suma(11, 19, 29);
- Console.WriteLine(total); // 59
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement