Convert string to decimal, keeping fractions

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

    The value is the same even though the printed representation is not what you expect:

    decimal d = (decimal )1200.00;
    Console.WriteLine(Decimal.Parse("1200") == d); //True
    

提交回复
热议问题