Take the 2-minute tour ×

I want to display multiple languages and UI cultures on my website. I have enabled the IIS 7 flag which picks up culture from the browser automatically as so:


This works perfectly in that the correct Resources files are loaded, and the correct culture is displayed (0.00 for GB; 0,00 for DE).

However this has had an unexpected problem of interferring with my external services, for example here is the code for interfacing with PayPal.

var paymentDetails = new PaymentDetailsType
    ItemTotal = new BasicAmountType
        currencyID = currencyCode,
        Value = basket.SubTotal.ToString("0.00")

This code basically creates a string formatted like so '50.25', however as PayPal always requires a dot decimal point, when a culture is selected that has a comma as a decimal point (for example DE - German) the ToString("0.00") generates '50,25' and so my code fails.

What would be the best method to correct this? I still want the culture set to the user's culture, however I want to set certain parts of my code to use my own culture.

I know I can feed in a specific culture to the ToString() method, but this seems very hackish. Any more professional clean approaches?

share|improve this question
Feeding in the specific culture is exactly what you need to do as that's what PayPal requires. –  Jeremy McGee Dec 29 '11 at 12:46

1 Answer 1

up vote 5 down vote accepted

Have a look at the InvariantCulture.

Value = basket.SubTotal.ToString("0.00", CultureInfo.InvariantCulture)

Here's a link to the overload of ToString() that takes a second System.IFormatProvider parameter: http://msdn.microsoft.com/en-us/library/d8ztz0sa.aspx

share|improve this answer

Your Answer


