Freigeben über


Display vs. Storage of Formatted Data 

Data, such as numbers and dates and time, can be formatted appropriately for a specific culture using methods, such as System.String.Format(System.IFormatProvider,System.String,System.Object[]), that can take a CultureInfo object as a parameter. Although you can format data using the implicit culture associated with the current thread, you can get more predictable results if you explicitly specify a culture.

You should consider the following three guidelines when deciding whether to format data for display in a user interface, or for storage in memory or a file:

  • Use the invariant culture to format data for storage, and use a culture specified by the user to reformat the data for display.

    Use the invariant culture to store data in a file or memory, or to transmit the data over a communication link. The reason is that the invariant culture yields data with a consistent format that can be compared, manipulated, and exchanged with other applications. If different data is formatted with different cultures, operations such as sorting might be impractical.

    If the stored data needs to be displayed, reformat the data for display using a culture that the user specifies.

  • The properties of a culture used for data display can differ from their standard values.

    Although the user might specify a particular culture for data display, user interface properties for that culture might differ from the standard values that you expect. This might happen if the user specifies a custom culture that has user interface properties with nonstandard values, or if the user overrides some of the user interface properties of the current culture by invoking the Regional and Language Options (or Regional Options or Regional Settings) in Control Panel.

  • International standards that govern data display formats can change over time.

    Cultures in the .NET Framework follow international standards that determine the format of dates, time, currency, and so on. However, international standards are not constant and formats can change. For example, a change can occur if a local government that has authority over a country/region mandates a new format. Consequently, if a data display format changes, you might need to update your application to use revised culture information.

See Also

Reference

CultureInfo