I recently made a post here (which is now marked as "answered" - which it is) about parsing Google Calc json strings into WP7 http://www.google.com/ig/calculator?hl=en&q=100GBP=?SEK.
It's working great - unless Google returns a number above 999. A number above 999 is writenn 1 000, instead of 1000. It seems like the "space" makes the application crash/try-catch aware that there's something wrong.
I just wonder how I can make the json serializer (using System.Runtime.Serialization.Json;) (using StringBuilder) return sum/amount(s) above 999, without crashing?
Thanks :)
CODE:
Hello! I'm mainly using the code found here: Parse Google Calculator with Json in Windows Phone 7 / C#?
In order to get currency landcodes from listbox, I use:
ListBoxItem toExchangeSelected= toCurrencyList.ItemContainerGenerator.ContainerFromItem(this.toCurrencyListtaListe.SelectedItem) as ListBoxItem;
string toCurrency = toCurrencyList.Content.ToString();
ListBoxItem fromExchangeSelected= fromCurrencyList.ItemContainerGenerator.ContainerFromItem(this.fromCurrencyList.SelectedItem) as ListBoxItem;
string fromCurrency = fromExchangeSelected.Content.ToString();
Certain European cultures use spaces instead of commas for large numbers, so try using the appropriate CultureInfo before you parse the string:
CultureInfo ci = new CultureInfo("fr-FR");
double d = double.Parse("1 000", ci); // returns 1000.0
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With