convert this string into decimal

前端 未结 4 1580
抹茶落季
抹茶落季 2020-12-04 03:59

Sounds easy but when I tried to achieve i\'m stock about how is the formatter to make this conversion this are some examples of strings that i need to convert to decimal

4条回答
  •  攒了一身酷
    2020-12-04 04:35

    I suspect your system culture is not English and has different number formatting rules. Try passing the invariant culture as the format provider:

    decimal d = Convert.ToDecimal("00.24", CultureInfo.InvariantCulture);
    

    You could also use Decimal.Parse:

    decimal d = Decimal.Parse("00.24", CultureInfo.InvariantCulture);
    

提交回复
热议问题