Convert string to decimal, keeping fractions

后端 未结 11 1335
走了就别回头了
走了就别回头了 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:38

    decimal d = 3.00 is still 3. I guess you want to show it some where on screen or print it on log file as 3.00. You can do following

    string str = d.ToString("F2");
    

    or if you are using database to store the decimal then you can set pricision value in database.

提交回复
热议问题