Marketplace Tip: CultureInfo.InvariantCulture

 image

After releasing a ‘Lite’ version of my Jamster application just before Christmas I have received a lot of comments from foreign downloaders that point to an obvious issue when running in other languages/culture settings.

Of course I  had tested code under several different language settings in the past, but was conscious that I hadn’t done so recently. 

A quick check running the emulator in French (see left – Settings->Region & Language) quickly revealed the culprit and an easy fix:

image

Without the second parameter the parsing assumes culture specific attributes, which are often undesirable.

http://msdn.microsoft.com/en-us/library/system.globalization.cultureinfo.invariantculture.aspx

 

image

Advertisements

~ by Ian on January 5, 2011.

3 Responses to “Marketplace Tip: CultureInfo.InvariantCulture”

  1. Of course it all depends what you’re parsing. If it’s user input then it’s likely they’ll enter using their own cultural bias, and using the InvarientCulture may fail. So for user input you should be using CultureInfo.CurrentUICulture, and of course the same for display output.

    Also note that Code Analysis has rules for missing culture parameters on lots of functions, but you need one of the professional VS SKUs for that.

  2. Hi Barry, thanks for the incite.

  3. wow, did I mean insight?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: