Convert string decimal to int

后端 未结 4 2004
-上瘾入骨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:55

    You should not have to Round the value as ToInt64(double) returns the rounded version already

            string value = "246246.246";
            Convert.ToInt64(Convert.ToDouble(value));
    

提交回复
热议问题