Culture invariant Decimal.TryParse()

In fact CultureInfo.InvariantCulture can be used here. The parameter expects IFormatProvider, an interface that CultureInfo implements. But InvariantCulture is invariant in the sense that it does not vary with the user’s settings.

In fact, there is no culture that accepts either , or . as decimal separator – they are all one or the other. You’ll have to find some other way to deal with data which can use either of these decimal separators.

Leave a Comment