NumberFormatInfo Classe
Importante
Algumas informações se referem a produtos de pré-lançamento que podem ser substancialmente modificados antes do lançamento. A Microsoft não oferece garantias, expressas ou implícitas, das informações aqui fornecidas.
Fornece informações específicas da cultura para formatação e análise de valores numéricos.
public ref class NumberFormatInfo sealed : IFormatProvider
public ref class NumberFormatInfo sealed : ICloneable, IFormatProvider
public sealed class NumberFormatInfo : IFormatProvider
public sealed class NumberFormatInfo : ICloneable, IFormatProvider
[System.Serializable]
public sealed class NumberFormatInfo : ICloneable, IFormatProvider
[System.Serializable]
[System.Runtime.InteropServices.ComVisible(true)]
public sealed class NumberFormatInfo : ICloneable, IFormatProvider
type NumberFormatInfo = class
interface IFormatProvider
type NumberFormatInfo = class
interface ICloneable
interface IFormatProvider
[<System.Serializable>]
type NumberFormatInfo = class
interface ICloneable
interface IFormatProvider
[<System.Serializable>]
[<System.Runtime.InteropServices.ComVisible(true)>]
type NumberFormatInfo = class
interface ICloneable
interface IFormatProvider
Public NotInheritable Class NumberFormatInfo
Implements IFormatProvider
Public NotInheritable Class NumberFormatInfo
Implements ICloneable, IFormatProvider
- Herança
-
NumberFormatInfo
- Atributos
- Implementações
O exemplo a seguir mostra como recuperar um NumberFormatInfo objeto para um objeto correspondente e usar o objeto recuperado para consultar informações de formatação de número para a cultura específica CultureInfo .
using namespace System;
using namespace System::Globalization;
using namespace System::Text;
int main()
{
StringBuilder^ builder = gcnew StringBuilder();
// Loop through all the specific cultures known to the CLR.
for each(CultureInfo^ culture in
CultureInfo::GetCultures (CultureTypes::SpecificCultures))
{
// Only show the currency symbols for cultures
// that speak English.
if (culture->TwoLetterISOLanguageName == "en")
{
// Display the culture name and currency symbol.
NumberFormatInfo^ numberFormat = culture->NumberFormat;
builder->AppendFormat("The currency symbol for '{0}'"+
"is '{1}'",culture->DisplayName,
numberFormat->CurrencySymbol);
builder->AppendLine();
}
}
Console::WriteLine(builder);
}
// This code produces the following output.
//
// The currency symbol for 'English (United States)' is '$'
// The currency symbol for 'English (United Kingdom)' is 'Ј'
// The currency symbol for 'English (Australia)' is '$'
// The currency symbol for 'English (Canada)' is '$'
// The currency symbol for 'English (New Zealand)' is '$'
// The currency symbol for 'English (Ireland)' is '?'
// The currency symbol for 'English (South Africa)' is 'R'
// The currency symbol for 'English (Jamaica)' is 'J$'
// The currency symbol for 'English (Caribbean)' is '$'
// The currency symbol for 'English (Belize)' is 'BZ$'
// The currency symbol for 'English (Trinidad and Tobago)' is 'TT$'
// The currency symbol for 'English (Zimbabwe)' is 'Z$'
// The currency symbol for 'English (Republic of the Philippines)' is 'Php'
using System;
using System.Globalization;
using System.Text;
public sealed class App
{
static void Main()
{
StringBuilder sb = new StringBuilder();
// Loop through all the specific cultures known to the CLR.
foreach (CultureInfo ci in CultureInfo.GetCultures(CultureTypes.SpecificCultures))
{
// Only show the currency symbols for cultures that speak English.
if (ci.TwoLetterISOLanguageName != "en") continue;
// Display the culture name and currency symbol.
NumberFormatInfo nfi = ci.NumberFormat;
sb.AppendFormat("The currency symbol for '{0}' is '{1}'",
ci.DisplayName, nfi.CurrencySymbol);
sb.AppendLine();
}
Console.WriteLine(sb.ToString());
}
}
// This code produces the following output.
//
// The currency symbol for 'English (United States)' is '$'
// The currency symbol for 'English (United Kingdom)' is '£'
// The currency symbol for 'English (Australia)' is '$'
// The currency symbol for 'English (Canada)' is '$'
// The currency symbol for 'English (New Zealand)' is '$'
// The currency symbol for 'English (Ireland)' is '?'
// The currency symbol for 'English (South Africa)' is 'R'
// The currency symbol for 'English (Jamaica)' is 'J$'
// The currency symbol for 'English (Caribbean)' is '$'
// The currency symbol for 'English (Belize)' is 'BZ$'
// The currency symbol for 'English (Trinidad and Tobago)' is 'TT$'
// The currency symbol for 'English (Zimbabwe)' is 'Z$'
// The currency symbol for 'English (Republic of the Philippines)' is 'Php'
Imports System.Globalization
Imports System.Text
Public Module Example
Public Sub Main()
Dim sb As New StringBuilder()
' Loop through all the specific cultures known to the CLR.
For Each ci In CultureInfo.GetCultures(CultureTypes.SpecificCultures)
' Only show the currency symbols for cultures that speak English.
If ci.TwoLetterISOLanguageName <> "en" Then Continue For
' Display the culture name and currency symbol.
Dim nfi As NumberFormatInfo = ci.NumberFormat
sb.AppendFormat("The currency symbol for '{0}' is '{1}'",
ci.DisplayName, nfi.CurrencySymbol)
sb.AppendLine()
Next
Console.WriteLine(sb.ToString())
End Sub
End Module
' The example displays output like the following:
' The currency symbol for 'English (United States)' is '$'
' The currency symbol for 'English (United Kingdom)' is '£'
' The currency symbol for 'English (Australia)' is '$'
' The currency symbol for 'English (Canada)' is '$'
' The currency symbol for 'English (New Zealand)' is '$'
' The currency symbol for 'English (Ireland)' is '?'
' The currency symbol for 'English (South Africa)' is 'R'
' The currency symbol for 'English (Jamaica)' is 'J$'
' The currency symbol for 'English (Caribbean)' is '$'
' The currency symbol for 'English (Belize)' is 'BZ$'
' The currency symbol for 'English (Trinidad and Tobago)' is 'TT$'
' The currency symbol for 'English (Zimbabwe)' is 'Z$'
' The currency symbol for 'English (Republic of the Philippines)' is 'Php'
' The currency symbol for 'English (India)' is 'Rs.'
' The currency symbol for 'English (Malaysia)' is 'RM'
' The currency symbol for 'English (Singapore)' is '$'
Para obter mais informações sobre essa API, consulte Comentários da API complementar para NumberFormatInfo.
Number |
Inicializa uma nova instância gravável da classe NumberFormatInfo que é independente da cultura (invariável). |
Currency |
Obtém ou define o número de casas decimais a ser usado em valores de moeda. |
Currency |
Obtém ou define a cadeia de caracteres a ser usada como separador decimal em valores de moeda. |
Currency |
Obtém ou define a cadeia de caracteres que separa grupos de dígitos à esquerda do decimal em valores de moeda. |
Currency |
Obtém ou define o número de dígitos em cada grupo à esquerda do decimal em valores de moeda. |
Currency |
Obtém ou define o padrão de formato para valores negativos de moeda. |
Currency |
Obtém ou define o padrão de formato para valores positivos de moeda. |
Currency |
Obtém ou define a cadeia de caracteres a ser usada como o símbolo de moeda. |
Current |
Obtém o NumberFormatInfo somente leitura que formata valores com base na cultura atual. |
Digit |
Obtém ou define um valor que especifica como a interface gráfica do usuário exibe a forma de um dígito. |
Invariant |
Obtém o objeto NumberFormatInfo somente leitura que é independente da cultura (invariável). |
Is |
Obtém um valor que indica se este objeto NumberFormatInfo é somente leitura. |
Na |
Obtém ou define a cadeia de caracteres que representa o valor de IEEE NaN (não é um número). |
Native |
Obtém ou define uma matriz de cadeia de caracteres de dígitos nativos equivalentes aos dígitos ocidentais de 0 a 9. |
Negative |
Obtém ou define a cadeia de caracteres que representa o infinito negativo. |
Negative |
Obtém ou define a cadeia de caracteres que indica que o número associado é negativo. |
Number |
Obtém ou define o número de casas decimais a ser usado em valores numéricos. |
Number |
Obtém ou define a cadeia de caracteres a ser usada como separador decimal em valores numéricos. |
Number |
Obtém ou define a cadeia de caracteres que separa grupos de dígitos à esquerda da vírgula decimal em valores numéricos. |
Number |
Obtém ou define o número de dígitos em cada grupo à esquerda do decimal em valores numéricos. |
Number |
Obtém ou define o padrão de formato para valores numéricos negativos. |
Percent |
Obtém ou define o número de casas decimais a ser usado em valores percentuais. |
Percent |
Obtém ou define a cadeia de caracteres a ser usada como o separador decimal em valores de porcentagem. |
Percent |
Obtém ou define a cadeia de caracteres que separa os grupos de dígitos à esquerda do separador decimal em valores de percentual. |
Percent |
Obtém ou define o número de dígitos em cada grupo à esquerda do decimal em valores percentuais. |
Percent |
Obtém ou define o padrão de formato dos valores percentuais negativos. |
Percent |
Obtém ou define o padrão de formato para valores percentuais positivos. |
Percent |
Obtém ou define a cadeia de caracteres a ser usada como o símbolo de porcentagem. |
Per |
Obtém ou define a cadeia de caracteres a ser usada como o símbolo por milha. |
Positive |
Obtém ou define a cadeia de caracteres que representa o infinito positivo. |
Positive |
Obtém ou define a cadeia de caracteres que indica que o número associado é positivo. |
Clone() |
Cria uma cópia superficial do objeto NumberFormatInfo. |
Equals(Object) |
Determina se o objeto especificado é igual ao objeto atual. (Herdado de Object) |
Get |
Obtém um objeto do tipo especificado que fornece um serviço de formatação de número. |
Get |
Serve como a função de hash padrão. (Herdado de Object) |
Get |
Obtém o NumberFormatInfo associado ao IFormatProvider especificado. |
Get |
Obtém o Type da instância atual. (Herdado de Object) |
Memberwise |
Cria uma cópia superficial do Object atual. (Herdado de Object) |
Read |
Retorna um wrapper NumberFormatInfo de somente leitura. |
To |
Retorna uma cadeia de caracteres que representa o objeto atual. (Herdado de Object) |
Produto | Versões |
---|---|
.NET | Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9 |
.NET Framework | 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET Standard | 1.0, 1.1, 1.2, 1.3, 1.4, 1.6, 2.0, 2.1 |
UWP | 10.0 |
Comentários do .NET
O .NET é um projeto código aberto. Selecione um link para fornecer comentários: