Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / January 2007

Tip: Looking for answers? Try searching our database.

Parsing an english-style double on an italian Windows system

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Massimo - 25 Jan 2007 19:48 GMT
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

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.