How to fix an application that has a problem with decimal separator

后端 未结 5 2089
有刺的猬
有刺的猬 2020-12-10 15:46

This post is about C# and .Net, but some info is valuable for other techonolgies.

Since I can remember, I\'ve been having problems with apps or games that c

5条回答
  •  旧时难觅i
    2020-12-10 16:30

    In my opinion, the approach should be following:

    1. in the internal storage, the numbers are just numbers. so no problem occurs.
    2. when parsing input text sources, you should parse them according to the locale the source is created in -- most probably, invariant culture
    3. when outputting the values to the user, format them according to the user-preferred locale. in C#, this means maintainging CurrentCulture (not CurrentUICulture, see here why).

    This should be relatively simple and cover all the cases.

    This all applies to the case when you are the application's author. For others' applications, the respective developers must fix their bugs themselves.

提交回复
热议问题