What is Cultureinfo.Invariantculture?

Asked

Viewed 2,403 times

9

I installed Resharper and on that stretch x.Id.ToString() he suggests changing to x.Id.ToString(CultureInfo.InvariantCulture).

What is CultureInfo.InvariantCulture and why that way is better?

1 answer

8


I believe that Resharper just wants you to be more explicit. Don’t make the mistake of using the default unintentionally.

It indicates that you want to treat the die in a neutral way, which the computer understands in a way universal. This is a counterpoint to a specific culture that matters most to humans to understand the data. It is never changed. Specific crops may be modified by legislation or other factors.

The ideal is to work with the invariant culture throughout the application except at the time of user interaction or exchange information with other components that require a specific culture.

  • 4

    Just to complement, regional language configurations interfere with value transformations in different types of data, such as double and string, adding comma or dot as decimal separator according to the regional language settings of the machine. When using Invariantculture you tell Runtime that you should ignore regional language settings and always work in universal language format.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.