Best way to convert string to decimal separator “.” and “,” insensitive way?

前端 未结 7 1143
北海茫月
北海茫月 2020-12-15 06:05

Application deals with strings that represent decimals that come from different cultures. For example \"1.1 and \"1,1\" is the same value.

I played with Deci

相关标签:
7条回答
  • 2020-12-15 06:51

    You have the following possibllities:

    1. You know the culture
      1. Use the current Culture setting, for which the computer is installed
      2. You let the user decide to set his culture -> user settings in your program
    2. You do not know the culture
      1. You must decide about it: you have to define and document your decision
      2. Guess: you try to parse, and try to parse, and try to ... until you get valid numbers
    0 讨论(0)
提交回复
热议问题