we got regional related web client, where currency is set as in regional format, which we parse like:
bool result = decimal.TryParse(currencyValue, NumberStyles.Currency, myCulture, out value);
when we serialize this decimal to xml and decimal was previously parsed in myCulture=en-US, xmlserializer returns <Curr id="2" amnt="100000000.00"/> and deserialize it back to same number… but when we do it in sk-SK or cs-CZ it returns <Curr id="2" amnt="100000000,00"/> which returns *100 on deserialization (ignores comma)…
is there possibility to remove this regional from decimal, or make it invariant?
(if I don’t want to convert it to string and parse back again to handle regionals)
so I write answer to my own question, to can close this theme…
there was a new interesting point, what I get today morning after begin working. Problematic decimal was added to the distionary before serializing, which is a little bit problem, because IDictionary can;t be serialized, until it implement IXmlSerializable. There are two methods to override, ReadXml and WriteXml. And here is the goal, in WriteXml there was used
decimalValue.ToString(), which makes the problem. I dont know why it is, but this.ToString()returns the missmatch results what I describe in question. I dont know, how it happens, because in testing project it works perfect, but in our full context don’t. But as agent Mulder believed, the truth is out thereSo only what I need to do, was
decimalValue.ToString()changing todecimalValue.ToString(CultureInfo.InvariantCulture)thx for your time.