问题
Please read the question before flagging as duplicate.
I found many questions on SO complaining that Decimal.Parse
doesn't keep trailing zeros. But for my case Decimal.Parse(String)
doesn't remove trailing zeros at all.
Decimal.Parse("3.000").ToString() ' ==> "3.000"
Double.Parse("3.000").ToString() ' ==> "3"
Am I missing something here?
回答1:
You can achieve this using number formatting
Decimal.Parse("3.100").ToString("G")
Or with some workaround like the following:
StrDec = Decimal.Parse("3.100").ToString
If strDec.Contains(".") Then strdec = strdec.TrimEnd("0")
来源:https://stackoverflow.com/questions/40953111/decimal-parse-doesnt-remove-trailing-zeros