I would like to take the sum of all the wages and divide by the amount of employees, but this one giving error, when compilo says that it has 0 in the variables Count
of the list and total.
public class Informacao
{
public float salBruto { get; set; }
public int numFilhos { get; set; }
}
class Ex2
{
List<Informacao> info = new List<Informacao>();
public void CadNovaPesquisa()
{
Informacao infoo = new Informacao();
Console.Clear();
Console.WriteLine("Informe seu salário bruto:");
infoo.salBruto = float.Parse(Console.ReadLine());
Console.WriteLine("Informe a quantidade de filhos:");
infoo.numFilhos = Convert.ToInt32(Console.ReadLine());
info.Add(infoo);
}
public void CalculaMedia()
{
int i = info.Count;
float total;
total = info.Sum(x => x.salBruto);
Console.WriteLine(i);
//float media = total / i;
Console.WriteLine($"TOTAL: {total}");
Console.ReadLine();
}