0
I have this method CadastroDespesas, only that he is making the wrong sum in foreach going through my list.
I don’t know what it is, if anyone can help me...
To totdesp is a global variable declared in my class).
class Ex4
{
    List<String> descricaodespesas = new List<string>();
    List<float> valordespesas = new List<float>();
    List<String> descricaoreceitas = new List<string>();
    List<float> valorreceitas = new List<float>();
    float totdesp, totreceit;
    float mediareceit, mediadesp;
    public void CadastroDespesas()
    {
        string descricao;
        float valor,somadesp = 0;
        Console.Write("Informe o valor: ");
        valor = Convert.ToSingle(Console.ReadLine());
        valordespesas.Add(valor);
        Console.WriteLine("Informe uma descrição:");
        descricao = (Console.ReadLine());
        descricaodespesas.Add(descricao);
        foreach (float som in valordespesas)
        {
            somadesp += valor;
        }
        totdesp = somadesp;
    }
}
						
Behold: How and why to accept an answer?
– Math
Read this: https://answall.com/q/219211/101
– Maniero