Best way to parse float?

后端 未结 10 1101
无人及你
无人及你 2020-12-02 22:52

What is the best way to parse a float in CSharp? I know about TryParse, but what I\'m particularly wondering about is dots, commas etc.

I\'m having problems with my

10条回答
  •  旧时难觅i
    2020-12-02 23:07

    I agree with leppie's reply; to put that in terms of code:

    string s = "123,456.789";
    float f = float.Parse(s, CultureInfo.InvariantCulture);
    

提交回复
热议问题