0
I’m having difficulty printing a monetary value correctly with the distribution of its decimal places, I used the ToString()
using parameters such as "C", "F" and "N", what needs to be done to leave a correct monetary value?
using static System.Console;
using System.Globalization;
namespace AtividadeRepeticao
{
class Program2
{
static int Main(string[] args)
{
double valor = 1000.50;
Write($"Valor: {valor.ToString("C", CultureInfo.CurrentCulture)}");
ReadKey();
return 0;
}
}
}
// Valor esperado
1.000,50
// Valor imprimido
100.050,00
You have a syntax error
Write($"R$: {valor.ToString("C", CultureInfo.CurrentCulture}));
, correct that there.– Augusto Vasques
I corrected the syntax here and did not present this result suggested in the question: outworking
– Augusto Vasques