-2
I would like that, somehow, after converting the string array to double, the values remain floating point. I put the input as, for example, 5.5 6.5 7.8 2.5 6.2, and during the conversion is not taken into account that are numbers with decimal place, they are concatenated and turns 55, 65, 78, 25 and 62.
I have tried the conversion in several ways. My ultimate goal was to accumulate the values summed into one variable.
string[] notas = new string[5];
Console.WriteLine("Informe 5 notas: ");
notas = Console.ReadLine().Split(' ');
for (int i = 0; i < entradas.Length; i++)
{
soma += Convert.ToDouble(entradas[i]); // a soma da errado pq considera os números concatenados
}
string[] notas = new string[5];
Console.WriteLine("Informe 5 notas: ");
notas = Console.ReadLine().Split(' ');
double[] vetor = notas.Select(Convert.ToDouble).ToArray(); // double[] vetor = Array.ConvertAll(notas, Convert.ToDouble);
for (int i = 0; i < notas.Length; i++)
{
soma += vetor[i]; // a soma da errado pq considera os números concatenados, não com o ponto flutuante
}
Thank you for the reading instructions and for the reply!
– Agatha França