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.