Working with globalization, string parsing and number formats in C#
On a project I attended a couple of years ago, we struggled a lot with string parsing, date formats and cultures. The product was shipped to among others China, Japan and US, and getting your code to work seamless in all culture formats can be a bit of a hassle if you are not fully familiar with how .Net and C# handles cultures and globalization. Back then I crated a small Windows Forms application to help me fully understand the details of conversions and parsing to avoid problems when our application was run on e.g. a Chinese laptop.
As you can see from the picture, is a very simple application, but it helped me allot to have this small application available whenever working on code directly related to globalization, parsing and cultures.
Today when I was looking through all my prototypes/test projects I came across this again, and decided that I might as well post this to my blog with the source code attached, as it might help others as well! Note especially the Parse String function which tests parsing of a string to a double. The input string 222.45 will we parsed correctly to a double in most cultures, but:
- To French: Failure
- To German: 22245
- To English (US): 222.45
- To Norwegian: Failure
So keep this small application close at hand to rather find the problems during development than at your customer French laptop! You can download the source code here.

January 2nd, 2010 - 19:14
hi,
First of all. Thanks very much for your useful post.
I just came across your blog and wanted to drop you a note telling you how impressed I was with the information you have posted here.
Please let me introduce you some info related to this post and I hope that it is useful for .Net community.
There is a good C# resource site, Have alook
http://www.csharptalk.com
simi