Best way to parse float?

后端 未结 10 1076
无人及你
无人及你 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条回答
  •  执笔经年
    2020-12-02 23:17

    Try to avoid float.Parse, use TryParse instead as it performs a lot better but does the same job. this also applies to double, DateTime, etc...

    (some types also offer TryParseExact which also performs even better!)

提交回复
热议问题