p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   BOOK: Stephens' C# Programming with Visual Studio 2010 24-Hour Trainer (http://p2p.wrox.com/forumdisplay.php?f=574)
-   -   Chapter 12 exercise 4 outside US (http://p2p.wrox.com/showthread.php?t=86053)

Joakim December 16th, 2011 10:14 AM

Chapter 12 exercise 4 outside US
Just some info for other forigen students….
I’m from Sweden and when I download the solution for 12-4 and try to run it I got FormatExeption.

I tried to pase my output in to this message so you could see what it loked like but it was not accepted

I tried to figure out the problem by reding the tips in the exeption but that didn’t help (I still need to learn more I think) so I did som trial and error or like it said in the book… I staired real hard at the code like they did on the old days (I’m a mainframeprogrammer converting to .NET. That’s the reason for me reding this book)

In Sweden we don’t write ammount like $10,000.00
Here propper amounts would be 10 000,00 or 10 000,00kr or 10.000,00kr
So by changing the text in all textboxes I finally got it to work.


Rod Stephens December 16th, 2011 10:31 AM

Lesson 34 has more to say about internationalization. I wrote all of the examples on my computer set up for United States English so things like monetary values use that format. So, as you noticed, they probably won't work properly in other countries. Sorry about the confusion.

You found the right solution: change the values to use your local formats. There are ways you can make things like int.Parse read formats from countries other than the one you're in but that would just confuse matters and not be all that helpful.

Note that values inside your code should always be in the United States formats. Not because those are better but to be consistent Microsoft had to pick something and, since they developed C# in the United States, that's the format they decided to use. Hopefully the difference won't be too annoying.

Joakim December 16th, 2011 10:42 AM

Thank’s Rod.
I just wanted to help/inform other students that might have the same problem.
I’ll struggle on. In January I will take a real class and by then I will hopefully have some basic knowledge about Visual Studio and C# in order to get the moste out of the class.
I’m really enyoying your book so far.

Rod Stephens December 16th, 2011 10:51 AM

I agree. It's the sort of issue that can be a real problem if you're new to all this. (I've worked on some big programs (written by other people) where a similar problem made them fail only in specific countries and only on some computers and it was a big hassle.)

If you get stuck like this again, feel free to let me know and I'll try to help. I hate to waste your time on something like this.

All times are GMT -4. The time now is 04:44 AM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.