Marketplace Tip: CultureInfo.InvariantCulture


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:


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




3 thoughts on “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.

Leave a Reply

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

You are commenting using your 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