NumberFormatInfo Clase
Definición
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
Ejemplos
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 '$'
Comentarios
Para obtener más información sobre esta API, consulte Comentarios complementarios de api para NumberFormatInfo.
Constructores
| NumberFormatInfo() |
Inicializa una nueva instancia de la clase NumberFormatInfo en la que se puede escribir y que es independiente de la referencia cultural (invariable). |
Propiedades
| CurrencyDecimalDigits |
Obtiene o establece el número de posiciones decimales que se van a utilizar en valores de divisa. |
| CurrencyDecimalSeparator |
Obtiene o establece la cadena que se va a utilizar como separador decimal en valores de divisa. |
| CurrencyGroupSeparator |
Obtiene o establece la cadena que separa grupos de dígitos a la izquierda de la coma decimal en valores de divisa. |
| CurrencyGroupSizes |
Obtiene o establece el número de dígitos en cada grupo a la izquierda de la coma decimal en valores de divisa. |
| CurrencyNegativePattern |
Obtiene o establece el modelo de formato para los valores de divisa negativos. |
| CurrencyPositivePattern |
Obtiene o establece el modelo de formato para los valores de divisa positivos. |
| CurrencySymbol |
Obtiene o establece la cadena que se va a utilizar como símbolo de divisa. |
| CurrentInfo |
Obtiene un NumberFormatInfo de solo lectura que aplica formato a los valores basándose en la referencia cultural actual. |
| DigitSubstitution |
Obtiene o establece un valor que especifica cómo la interfaz gráfica de usuario muestra la forma de un dígito. |
| InvariantInfo |
Obtiene un objeto NumberFormatInfo de solo lectura que es independiente de la referencia cultural (invariable). |
| IsReadOnly |
Obtiene un valor que indica si este objeto NumberFormatInfo es de solo lectura. |
| NaNSymbol |
Obtiene o establece la cadena que representa el valor NaN (no un número) de IEEE. |
| NativeDigits |
Obtiene o establece una matriz de cadenas de dígitos nativos equivalentes a los dígitos occidentales del 0 al 9. |
| NegativeInfinitySymbol |
Obtiene o establece la cadena que representa un infinito negativo. |
| NegativeSign |
Obtiene o establece la cadena que denota que el número asociado es negativo. |
| NumberDecimalDigits |
Obtiene o establece el número de posiciones decimales que se van a utilizar en valores numéricos. |
| NumberDecimalSeparator |
Obtiene o establece la cadena que se va a utilizar como separador decimal en valores numéricos. |
| NumberGroupSeparator |
Obtiene o establece la cadena que separa grupos de dígitos a la izquierda de la coma decimal en valores numéricos. |
| NumberGroupSizes |
Obtiene o establece el número de dígitos en cada grupo a la izquierda de la coma decimal en valores numéricos. |
| NumberNegativePattern |
Obtiene o establece el modelo de formato para los valores numéricos negativos. |
| PercentDecimalDigits |
Obtiene o establece el número de posiciones decimales que se van a utilizar en valores de porcentaje. |
| PercentDecimalSeparator |
Obtiene o establece la cadena que se va a utilizar como separador decimal en valores de porcentaje. |
| PercentGroupSeparator |
Obtiene o establece la cadena que separa grupos de dígitos a la izquierda de la coma decimal en valores de porcentaje. |
| PercentGroupSizes |
Obtiene o establece el número de dígitos en cada grupo a la izquierda de la coma decimal en valores de porcentaje. |
| PercentNegativePattern |
Obtiene o establece el modelo de formato para los valores de porcentaje negativos. |
| PercentPositivePattern |
Obtiene o establece el modelo de formato para los valores de porcentaje positivos. |
| PercentSymbol |
Obtiene o establece la cadena que se va a utilizar como símbolo de porcentaje. |
| PerMilleSymbol |
Obtiene o establece la cadena que se va a utilizar como símbolo de por mil. |
| PositiveInfinitySymbol |
Obtiene o establece la cadena que representa un infinito positivo. |
| PositiveSign |
Obtiene o establece la cadena que denota que el número asociado es positivo. |
Métodos
| Clone() |
Crea una copia superficial del objeto NumberFormatInfo. |
| Equals(Object) |
Determina si el objeto especificado es igual que el objeto actual. (Heredado de Object) |
| GetFormat(Type) |
Obtiene un objeto del tipo especificado que proporciona un servicio de formato numérico. |
| GetHashCode() |
Sirve como la función hash predeterminada. (Heredado de Object) |
| GetInstance(IFormatProvider) |
Obtiene el objeto NumberFormatInfo asociado al IFormatProvider especificado. |
| GetType() |
Obtiene el Type de la instancia actual. (Heredado de Object) |
| MemberwiseClone() |
Crea una copia superficial del Object actual. (Heredado de Object) |
| ReadOnly(NumberFormatInfo) |
Devuelve un contenedor de NumberFormatInfo de solo lectura. |
| ToString() |
Devuelve una cadena que representa el objeto actual. (Heredado de Object) |