As the title implies, I'm in need of reading a double number from a text
file, but the file follows english-style syntax, while the application is
running on an italian-language Windows system; this causes some troubles,
because in Italy we use "." to separate thousands and "," for decimal
digits, while the english number format does exactly the opposite.
I know there must be some way to tell double.Parse() to use a different
number format, but I really don't know how to do this; I suppose
double.Parse(String,IFormatProvider) can do the trick, but I don't seem to
be able to find any information about how to use it.
Can someone please help?
Thanks
Massimo
Joerg Jooss - 25 Jan 2007 20:00 GMT
Thus wrote Massimo,
> As the title implies, I'm in need of reading a double number from a
> text file, but the file follows english-style syntax, while the
[quoted text clipped - 9 lines]
>
> Can someone please help?
Create a CultureInfo for "en-US" (or "en-GB") and pass this as IFormatProvider:
// Prints "10000"
Console.WriteLine(Double.Parse("10,000", new CultureInfo("en-US")));
Cheers,

Signature
Joerg Jooss
news-reply@joergjooss.de
Massimo - 25 Jan 2007 20:10 GMT
> Create a CultureInfo for "en-US" (or "en-GB") and pass this as
> IFormatProvider:
>
> // Prints "10000"
> Console.WriteLine(Double.Parse("10,000", new CultureInfo("en-US")));
Thanks.
I know it should have been quite simple, but MSDN docs are so huge sometimes
it's difficult to find what you need.
Massimo