如何处理文化在C#双解析? [英] how to handle culture in double parsing in c#?
问题描述
我有一个关于如何处理文化在分析双打的问题。
在来自不同服务器的系统的价格信息汇集在一起。
但是数据这就是作为输入给出培养而变化。
两万元,五毛给定为:结果
2.000.000,50结果
2,000,000.50结果
2000000.50结果
2000000,50结果
I have a question about how to handle culture while parsing doubles.
In a system price information from various servers comes together.
However the data thats given as input varies in culture.
two million and fifty cents is given as :
"2.000.000,50"
"2,000,000.50"
"2000000.50"
"2000000,50"
有没有来处理这些不同类型的输入?
is there a generic way to handle these various types of input ?
推荐答案
没有,有没有通用的方法。要么你需要知道什么文化双击
格式化或所有的服务器都需要在一个单一的格式发送,比如 InvariantCulture的
。
No, there is no generic way. You either need to know what culture the double
was formatted or all the servers need to send in a single format, say InvariantCulture
.
如果你猜的文化,有一个坏消息等着你作为不同文化使用不同的小数点,组分隔符等等,所以你不能。
If you guess the culture, there's a bad news waiting for you as different cultures use different decimal separator, group separator etc. So you can't.
这篇关于如何处理文化在C#双解析?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!