I am trying to convert 1200.00
to decimal
, but Decimal.Parse()
removes .00
. I've tried some different methods, but it always removes .00
, except when I supply a fraction different than 0.
string value = "1200.00";
var convertDecimal = Decimal.Parse(value , NumberStyles.AllowThousands
| NumberStyles.AllowDecimalPoint | NumberStyles.AllowCurrencySymbol);
var convertDecimal = Convert.ToDecimal(value);
var convertDecimal = Decimal.Parse(value,
NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture);
How can I convert a string
containing 1200.00
to a decimal
containing 1200.00
?