3
I would like to show the mediadesp and mediareceit with 2 decimal places after the comma.
private void MediaReceitaseDespesas()
{
/* ----TOTAL / QTDE DE VALORES INFORMADOS----*/
mediadesp = somadesp / despesas.Count;
mediareceit = somareceit / receitas.Count;
Console.WriteLine($"A média das despesas foi de: {mediadesp} R$");
Console.WriteLine();
Console.WriteLine($"A média das receitas foi de: {mediareceit} R$");
Console.WriteLine();
Console.ReadLine();
}
you can’t tell much by your code... but try
mediadesp.ToString("C2")
then you can even remove that 'R$'– Rovann Linhalis
I voted for the best answer that gives the real solution. Working is different from being right: https://i.stack.Imgur.com/xG2Nn.png https://answall.com/q/219211/101
– Maniero