Convert string to decimal, keeping fractions

后端 未结 11 1359
走了就别回头了
走了就别回头了 2020-11-28 13:31

I am trying to convert 1200.00 to decimal, but Decimal.Parse() removes .00. I\'ve tried some different methods, but it al

11条回答
  •  悲&欢浪女
    2020-11-28 13:56

    The use of CultureInfo class worked for me, I hope help you.

        string value = "1200.00";
        CultureInfo culture = new CultureInfo("en-US");
        decimal result = Convert.ToDecimal(value, culture);
    

提交回复
热议问题