4
I have a database where product values are stored.
When there is occurrence of numbers with zero after commas they come without zero.
I did a test and with decimal it worked, but my application uses the type float, then I need to make it work with float.
decimal numero = decimal.Parse("50,00");
string resultado = numero.ToString();
Console.Write(resultado); /* Resultado: 50,00 */
I’m using a float that allows nulls:
float? numero = null;
The result of your code is
5000
for me.Decimal.Parse
seems to ignore commas. Also decimal types do not store the amount of zeros to the right of the original number, but you can force a specific amount by formatting as a string again.– Guilherme Bernal