Compartilhar via


Classes específicas de cultura para Windows Forms e Web Forms Globais

Each culture has different conventions for displaying dates, time, numbers, currency, and other information. O System.Globalization namespace contém classes que podem ser usados para modificar os valores específicos de cultura como são exibidos, como DateTimeFormatInfo, calendário, e NumberFormatInfo.

Using the Culture Setting

Mas a maioria das vezes, você usará a configuração de cultura, armazenada no aplicativo ou do Opções regionais o painel de controle, para determinar as convenções em tempo de execução e formatar a informação adequadamente automaticamente. Para obter mais informações sobre como definir a cultura, consulte Como: Set the Culture and UI Culture for Windows Forms Globalization ou Como: definir a cultura e interfaces de usuário da cultura para globalização de páginas da Web do ASP.NET. Classes que formatam automaticamente informações de acordo com a configuração de cultura são chamadas específicas de cultura. Alguns métodos específicos de cultura são IFormattable.ToString, Console.WriteLine, e String.Format. Algumas funções específicas de cultura (na linguagem de Visual Basic) são MonthName e WeekDayName.

Por exemplo, o código a seguir mostra como você pode usar o ToString método para o formato de moeda para a cultura atual:

' Put the Imports statements at the beginning of the code module
Imports System.Threading
Imports System.Globalization
' Display a number with the culture-specific currency formatting
Dim MyInt As Integer = 100
Console.WriteLine(MyInt.ToString("C", Thread.CurrentThread.CurrentCulture))
// 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:

100,00

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

$100.00

Consulte também

Referência

IFormattable.ToString

DateTimeFormatInfo

NumberFormatInfo

Calendar

Console.WriteLine

String.Format

Outros recursos

Globalizando e Localizando Aplicativos