I have an application where the price should go in int
format without decimals.
int Valor = (int)(produto.Valor * 100); //o produto.Valor é um decimal
The problem is when I want to display this value in View
For products like 0.10 it displays 0
int Valor = (int)(produto.Valor * 100);
Value is 10, equivalent to 0.10 (perfect here)
I tried:
@{
decimal Valor = Model.ValorExibicao / 100; //ValorExibicao é um int
}
@Valor.ToString("C", System.Globalization.CultureInfo.GetCultureInfo("pt-br"))
Shows $ 0.00
I tried:
@Convert.ToDouble(Model.ValorExibicao/ 100);
Displays 0
Only @Model.ValorExibicao
shows the correct 10 (equivalent to 0.10)
I could create in viewModel the correct value without formatting, however I think it would be a trick to get around an error of mine.