2
I have a way:
public static int soma(params int[] n)
{
int resultado = 0;
for (int i = 0; i < n.Length; i++)
{
resultado += n[i];
}
return resultado;
}
On my console:
List<int> numeros = new List<int>();
Console.WriteLine("Digite um numero");
numeros.Add(int.Parse((Console.ReadLine())));
resultado = soma(numeros); //Gera erro de conversão de list Generics para int
I’m wondering how to pass a list of entire parameters that the user types to the method. And also how you let the user stop typing to make the sum. Ex: it goes typing [1 2 3 4 5 6 8 9] and wants to stop and add, I’m not knowing the command to interrupt.