Culture-Specific Classes for Global Windows Forms and Web Forms


For the latest documentation on Visual Studio 2017, see Visual Studio 2017 Documentation.

Each culture has different conventions for displaying dates, time, numbers, currency, and other information. The System.Globalization namespace contains classes that can be used to modify how culture-specific values are displayed, such as DateTimeFormatInfo, Calendar, and NumberFormatInfo.

But most of the time you will use the culture setting, stored either in the application or in the Regional Options control panel, to automatically determine the conventions at run time and format the information accordingly. For more information on setting the culture, see How to: Set the Culture and UI Culture for Windows Forms Globalization or How to: Set the Culture and UI Culture for ASP.NET Web Page Globalization. Classes that automatically format information according to the culture setting are called culture-specific. Some culture-specific methods are IFormattable.ToString, Console.WriteLine, and String.Format. Some culture-specific functions (in the Visual Basic language) are MonthName and WeekDayName.

For example, the following code shows how you can use the ToString method to format currency for the current culture:

// Put the using statements at the beginning of the code module  
using System.Threading;  
using System.Globalization;  
// Display a number with the culture-specific currency formatting  
int myInt = 100;  
Console.WriteLine(myInt.ToString("C", Thread.CurrentThread.CurrentCulture));  

If the culture is set to "fr-FR", you will see this in the output window:


If the culture is set to "en-US", you will see this in the output window:


Globalizing and Localizing Applications