How do I convert the string “39.9983%” into “39%” in C#?

后端 未结 8 1045
一整个雨季
一整个雨季 2021-01-16 07:46

I don\'t want to do any rounding, straight up, \"39%\".

So \"9.99%\" should become \"9%\".

相关标签:
8条回答
  • 2021-01-16 08:38

    Now we have two questions asking the same thing..

    Heres my crack at it.

    "39.9983%".Split('.')[0] + "%";
    
    0 讨论(0)
  • 2021-01-16 08:42

    I hope this will work.

    string str = "39.999%";

    string[] Output = str.Split('.');

    Output[0] will have your Answer.

    Thanks

    0 讨论(0)
提交回复
热议问题