How could I convert data from string to long in c#

前端 未结 9 2151
慢半拍i
慢半拍i 2021-02-02 04:45

How could i convert data from string to long in C#?

I have data

String strValue[i] =\"1100.25\";

now i want it in

long         


        
9条回答
  •  广开言路
    2021-02-02 05:26

    If you want to get the integer part of that number you must first convert it to a floating number then cast to long.

    long l1 = (long)Convert.ToDouble("1100.25");
    

    You can use Math class to round up the number as you like, or just truncate...

    • Math.Round
    • Math.Ceil

提交回复
热议问题