Remove decimal point from a decimal number

前端 未结 7 2133
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-19 01:32

I am trying to remove just the decimal point from a decimal number in C#.

For example:

  • My decimal number is 2353.61 I want 235361
相关标签:
7条回答
  • 2021-01-19 02:07

    Maybe something like this(if the dot is in an unknown place - otherwise it's a simple multipication):

    string str = decNum.ToString().Replace(".",string.Empty);
    decimal dec = decimal.Parse(str);
    
    0 讨论(0)
提交回复
热议问题