NumberFormatInfo Clase
En este artículo
Importante
Parte de la información hace referencia a la versión preliminar del producto, que puede haberse modificado sustancialmente antes de lanzar la versión definitiva. Microsoft no otorga ninguna garantía, explícita o implícita, con respecto a la información proporcionada aquí.
Proporciona información de formato específica de la referencia cultural y los valores numéricos de análisis.
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
- Herencia
-
NumberFormatInfo
- Atributos
- Implementaciones
En el ejemplo siguiente se muestra cómo recuperar un NumberFormatInfo objeto para un objeto correspondiente CultureInfo y usar el objeto recuperado para consultar la información de formato de números para la referencia cultural concreta.
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 obtener más información sobre esta API, consulte Comentarios complementarios de api para NumberFormatInfo.
Number |
Inicializa una nueva instancia de la clase NumberFormatInfo en la que se puede escribir y que es independiente de la referencia cultural (invariable). |
Currency |
Obtiene o establece el número de posiciones decimales que se van a utilizar en valores de divisa. |
Currency |
Obtiene o establece la cadena que se va a utilizar como separador decimal en valores de divisa. |
Currency |
Obtiene o establece la cadena que separa grupos de dígitos a la izquierda de la coma decimal en valores de divisa. |
Currency |
Obtiene o establece el número de dígitos en cada grupo a la izquierda de la coma decimal en valores de divisa. |
Currency |
Obtiene o establece el modelo de formato para los valores de divisa negativos. |
Currency |
Obtiene o establece el modelo de formato para los valores de divisa positivos. |
Currency |
Obtiene o establece la cadena que se va a utilizar como símbolo de divisa. |
Current |
Obtiene un NumberFormatInfo de solo lectura que aplica formato a los valores basándose en la referencia cultural actual. |
Digit |
Obtiene o establece un valor que especifica cómo la interfaz gráfica de usuario muestra la forma de un dígito. |
Invariant |
Obtiene un objeto NumberFormatInfo de solo lectura que es independiente de la referencia cultural (invariable). |
Is |
Obtiene un valor que indica si este objeto NumberFormatInfo es de solo lectura. |
Na |
Obtiene o establece la cadena que representa el valor NaN (no un número) de IEEE. |
Native |
Obtiene o establece una matriz de cadenas de dígitos nativos equivalentes a los dígitos occidentales del 0 al 9. |
Negative |
Obtiene o establece la cadena que representa un infinito negativo. |
Negative |
Obtiene o establece la cadena que denota que el número asociado es negativo. |
Number |
Obtiene o establece el número de posiciones decimales que se van a utilizar en valores numéricos. |
Number |
Obtiene o establece la cadena que se va a utilizar como separador decimal en valores numéricos. |
Number |
Obtiene o establece la cadena que separa grupos de dígitos a la izquierda de la coma decimal en valores numéricos. |
Number |
Obtiene o establece el número de dígitos en cada grupo a la izquierda de la coma decimal en valores numéricos. |
Number |
Obtiene o establece el modelo de formato para los valores numéricos negativos. |
Percent |
Obtiene o establece el número de posiciones decimales que se van a utilizar en valores de porcentaje. |
Percent |
Obtiene o establece la cadena que se va a utilizar como separador decimal en valores de porcentaje. |
Percent |
Obtiene o establece la cadena que separa grupos de dígitos a la izquierda de la coma decimal en valores de porcentaje. |
Percent |
Obtiene o establece el número de dígitos en cada grupo a la izquierda de la coma decimal en valores de porcentaje. |
Percent |
Obtiene o establece el modelo de formato para los valores de porcentaje negativos. |
Percent |
Obtiene o establece el modelo de formato para los valores de porcentaje positivos. |
Percent |
Obtiene o establece la cadena que se va a utilizar como símbolo de porcentaje. |
Per |
Obtiene o establece la cadena que se va a utilizar como símbolo de por mil. |
Positive |
Obtiene o establece la cadena que representa un infinito positivo. |
Positive |
Obtiene o establece la cadena que denota que el número asociado es positivo. |
Clone() |
Crea una copia superficial del objeto NumberFormatInfo. |
Equals(Object) |
Determina si el objeto especificado es igual que el objeto actual. (Heredado de Object) |
Get |
Obtiene un objeto del tipo especificado que proporciona un servicio de formato numérico. |
Get |
Sirve como la función hash predeterminada. (Heredado de Object) |
Get |
Obtiene el objeto NumberFormatInfo asociado al IFormatProvider especificado. |
Get |
Obtiene el Type de la instancia actual. (Heredado de Object) |
Memberwise |
Crea una copia superficial del Object actual. (Heredado de Object) |
Read |
Devuelve un contenedor de NumberFormatInfo de solo lectura. |
To |
Devuelve una cadena que representa el objeto actual. (Heredado de Object) |
Producto | Versiones |
---|---|
.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 |
Comentarios de .NET
.NET es un proyecto de código abierto. Seleccione un vínculo para proporcionar comentarios: