NumberFormatInfo Klasa

Definicja

Udostępnia informacje specyficzne dla kultury do formatowania i analizowania wartości liczbowych.

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
Dziedziczenie
NumberFormatInfo
Atrybuty
Implementuje

Przykłady

W poniższym przykładzie pokazano, jak pobrać NumberFormatInfo obiekt dla odpowiedniego CultureInfo obiektu i użyć pobranego obiektu w celu utworzenia zapytania o informacje dotyczące formatowania liczb dla określonej kultury.

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 '$'

Uwagi

Aby uzyskać więcej informacji na temat tego interfejsu API, zobacz Uwagi dotyczące dodatkowego interfejsu API dla parametru NumberFormatInfo.

Konstruktory

NumberFormatInfo()

Inicjuje nowe zapisywalne wystąpienie NumberFormatInfo klasy, która jest niezależna od kultury (niezmienna).

Właściwości

CurrencyDecimalDigits

Pobiera lub ustawia liczbę miejsc dziesiętnych do użycia w wartościach waluty.

CurrencyDecimalSeparator

Pobiera lub ustawia ciąg do użycia jako separator dziesiętny w wartościach waluty.

CurrencyGroupSeparator

Pobiera lub ustawia ciąg, który oddziela grupy cyfr po lewej stronie wartości dziesiętnych w wartościach waluty.

CurrencyGroupSizes

Pobiera lub ustawia liczbę cyfr w każdej grupie po lewej stronie wartości dziesiętnych w walucie.

CurrencyNegativePattern

Pobiera lub ustawia wzorzec formatu dla wartości ujemnych waluty.

CurrencyPositivePattern

Pobiera lub ustawia wzorzec formatu dla dodatnich wartości walutowych.

CurrencySymbol

Pobiera lub ustawia ciąg do użycia jako symbol waluty.

CurrentInfo

Pobiera tylko do NumberFormatInfo odczytu, który formatuje wartości na podstawie bieżącej kultury.

DigitSubstitution

Pobiera lub ustawia wartość określającą sposób wyświetlania kształtu cyfry przez graficzny interfejs użytkownika.

InvariantInfo

Pobiera obiekt tylko do NumberFormatInfo odczytu, który jest niezależny od kultury (niezmienny).

IsReadOnly

Pobiera wartość wskazującą, czy ten NumberFormatInfo obiekt jest tylko do odczytu.

NaNSymbol

Pobiera lub ustawia ciąg reprezentujący wartość IEEE NaN (nie liczba).

NativeDigits

Pobiera lub ustawia tablicę ciągów cyfr natywnych równoważną cyfrom zachodnim od 0 do 9.

NegativeInfinitySymbol

Pobiera lub ustawia ciąg reprezentujący ujemną nieskończoność.

NegativeSign

Pobiera lub ustawia ciąg, który oznacza, że skojarzona liczba jest ujemna.

NumberDecimalDigits

Pobiera lub ustawia liczbę miejsc dziesiętnych do użycia w wartościach liczbowych.

NumberDecimalSeparator

Pobiera lub ustawia ciąg do użycia jako separator dziesiętny w wartościach liczbowych.

NumberGroupSeparator

Pobiera lub ustawia ciąg, który oddziela grupy cyfr po lewej stronie wartości dziesiętnych w wartościach liczbowych.

NumberGroupSizes

Pobiera lub ustawia liczbę cyfr w każdej grupie po lewej stronie dziesiętnej w wartościach liczbowych.

NumberNegativePattern

Pobiera lub ustawia wzorzec formatu dla ujemnych wartości liczbowych.

PercentDecimalDigits

Pobiera lub ustawia liczbę miejsc dziesiętnych do użycia w wartościach procentowych.

PercentDecimalSeparator

Pobiera lub ustawia ciąg do użycia jako separator dziesiętny w wartościach procentowych.

PercentGroupSeparator

Pobiera lub ustawia ciąg, który oddziela grupy cyfr po lewej stronie wartości dziesiętnych w procentach.

PercentGroupSizes

Pobiera lub ustawia liczbę cyfr w każdej grupie po lewej stronie wartości dziesiętnych w procentach.

PercentNegativePattern

Pobiera lub ustawia wzorzec formatu dla wartości ujemnych procent.

PercentPositivePattern

Pobiera lub ustawia wzorzec formatu dla wartości procentu dodatniego.

PercentSymbol

Pobiera lub ustawia ciąg do użycia jako symbol procentu.

PerMilleSymbol

Pobiera lub ustawia ciąg do użycia jako symbol per mille.

PositiveInfinitySymbol

Pobiera lub ustawia ciąg reprezentujący nieskończoność dodatnią.

PositiveSign

Pobiera lub ustawia ciąg, który oznacza, że skojarzona liczba jest dodatnia.

Metody

Clone()

Tworzy płytkią kopię NumberFormatInfo obiektu.

Equals(Object)

Określa, czy dany obiekt jest taki sam, jak bieżący obiekt.

(Odziedziczone po Object)
GetFormat(Type)

Pobiera obiekt określonego typu, który udostępnia usługę formatowania liczb.

GetHashCode()

Służy jako domyślna funkcja skrótu.

(Odziedziczone po Object)
GetInstance(IFormatProvider)

NumberFormatInfo Pobiera element skojarzony z określonym IFormatProviderelementem .

GetType()

Type Pobiera bieżące wystąpienie.

(Odziedziczone po Object)
MemberwiseClone()

Tworzy płytkią kopię bieżącego Objectelementu .

(Odziedziczone po Object)
ReadOnly(NumberFormatInfo)

Zwraca otokę tylko do NumberFormatInfo odczytu.

ToString()

Zwraca ciąg reprezentujący bieżący obiekt.

(Odziedziczone po Object)

Dotyczy

Zobacz też