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

后端 未结 5 2088
有刺的猬
有刺的猬 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条回答
  •  星月不相逢
    2020-12-10 16:23

    There isn't a silver bullet here.

    Some suggestions:

    The invariant culture can be used when dealing with internal data that is stored in a config file. This way no matter what culture the machine is you can read and write your own internal data in a consistent manner.

    See here:

    http://msdn.microsoft.com/en-us/library/4c5zdc6a.aspx

    Other problems deal with something simple as string.ToLower().

    Seems innocent enough, until you try to lowercase an English letter than doesn't exist in the current culture. (E.G. Turkish)

    In these cases, calling string.ToLower() should be replaced with the culture overload and the current culture or invariant culture should be passed (depending on your situation).

    Definately some pitfalls to watch out for.

提交回复
热议问题