Convert string decimal to int

后端 未结 4 2011
-上瘾入骨i
-上瘾入骨i 2020-12-09 15:30

I have a string \"246246.246\" that I\'d like to pass to the IConvertable interface, ToInt16, ToInt32, ToIn64. What is the best way to parse a string with decimal places to

4条回答
  •  星月不相逢
    2020-12-09 15:52

    If you are really worry about accuracy but not about speed then decimal type would be better.

    (long)Math.Round(decimal.Parse(value));
    

提交回复
热议问题