NumberFormatInfo Kelas

Definisi

Menyediakan informasi khusus budaya untuk memformat dan mengurai nilai numerik.

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
Warisan
NumberFormatInfo
Atribut
Penerapan

Contoh

Contoh berikut menunjukkan cara mengambil NumberFormatInfo objek untuk objek terkait CultureInfo , dan menggunakan objek yang diambil untuk mengkueri informasi pemformatan nomor untuk budaya tertentu.

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

Keterangan

Untuk informasi selengkapnya tentang API ini, lihat Keterangan API Tambahan untuk NumberFormatInfo.

Konstruktor

NumberFormatInfo()

Menginisialisasi instans baru yang dapat ditulis dari NumberFormatInfo kelas yang independen budaya (invarian).

Properti

CurrencyDecimalDigits

Mendapatkan atau mengatur jumlah tempat desimal untuk digunakan dalam nilai mata uang.

CurrencyDecimalSeparator

Mendapatkan atau mengatur string yang akan digunakan sebagai pemisah desimal dalam nilai mata uang.

CurrencyGroupSeparator

Mendapatkan atau mengatur string yang memisahkan grup digit di sebelah kiri desimal dalam nilai mata uang.

CurrencyGroupSizes

Mendapatkan atau mengatur jumlah digit di setiap grup di sebelah kiri desimal dalam nilai mata uang.

CurrencyNegativePattern

Mendapatkan atau mengatur pola format untuk nilai mata uang negatif.

CurrencyPositivePattern

Mendapatkan atau mengatur pola format untuk nilai mata uang positif.

CurrencySymbol

Mendapatkan atau mengatur string yang akan digunakan sebagai simbol mata uang.

CurrentInfo

Mendapatkan baca-saja NumberFormatInfo yang memformat nilai berdasarkan budaya saat ini.

DigitSubstitution

Mendapatkan atau mengatur nilai yang menentukan bagaimana antarmuka pengguna grafis menampilkan bentuk digit.

InvariantInfo

Mendapatkan objek baca-saja NumberFormatInfo yang independen budaya (invarian).

IsReadOnly

Mendapatkan nilai yang menunjukkan apakah objek ini NumberFormatInfo baca-saja.

NaNSymbol

Mendapatkan atau mengatur string yang mewakili nilai IEEE NaN (bukan angka).

NativeDigits

Mendapatkan atau mengatur array string digit asli yang setara dengan digit Barat 0 hingga 9.

NegativeInfinitySymbol

Mendapatkan atau mengatur string yang mewakili tak terbatas negatif.

NegativeSign

Mendapatkan atau mengatur string yang menunjukkan bahwa angka terkait negatif.

NumberDecimalDigits

Mendapatkan atau mengatur jumlah tempat desimal yang akan digunakan dalam nilai numerik.

NumberDecimalSeparator

Mendapatkan atau mengatur string yang akan digunakan sebagai pemisah desimal dalam nilai numerik.

NumberGroupSeparator

Mendapatkan atau mengatur string yang memisahkan grup digit di sebelah kiri desimal dalam nilai numerik.

NumberGroupSizes

Mendapatkan atau mengatur jumlah digit di setiap grup di sebelah kiri desimal dalam nilai numerik.

NumberNegativePattern

Mendapatkan atau mengatur pola format untuk nilai numerik negatif.

PercentDecimalDigits

Mendapatkan atau mengatur jumlah tempat desimal untuk digunakan dalam nilai persen.

PercentDecimalSeparator

Mendapatkan atau mengatur string yang akan digunakan sebagai pemisah desimal dalam nilai persen.

PercentGroupSeparator

Mendapatkan atau mengatur string yang memisahkan grup digit di sebelah kiri desimal dalam nilai persen.

PercentGroupSizes

Mendapatkan atau mengatur jumlah digit di setiap grup di sebelah kiri desimal dalam nilai persen.

PercentNegativePattern

Mendapatkan atau mengatur pola format untuk nilai persentase negatif.

PercentPositivePattern

Mendapatkan atau mengatur pola format untuk nilai persentase positif.

PercentSymbol

Mendapatkan atau mengatur string yang akan digunakan sebagai simbol persen.

PerMilleSymbol

Mendapatkan atau mengatur string yang akan digunakan sebagai simbol per mille.

PositiveInfinitySymbol

Mendapatkan atau mengatur string yang mewakili tak terbatas positif.

PositiveSign

Mendapatkan atau mengatur string yang menunjukkan bahwa angka terkait positif.

Metode

Clone()

Membuat salinan objek yang NumberFormatInfo dangkal.

Equals(Object)

Menentukan apakah objek yang ditentukan sama dengan objek saat ini.

(Diperoleh dari Object)
GetFormat(Type)

Mendapatkan objek dari jenis yang ditentukan yang menyediakan layanan pemformatan angka.

GetHashCode()

Berfungsi sebagai fungsi hash default.

(Diperoleh dari Object)
GetInstance(IFormatProvider)

Mendapatkan yang NumberFormatInfo terkait dengan yang ditentukan IFormatProvider.

GetType()

Mendapatkan dari instans Type saat ini.

(Diperoleh dari Object)
MemberwiseClone()

Membuat salinan dangkal dari saat ini Object.

(Diperoleh dari Object)
ReadOnly(NumberFormatInfo)

Mengembalikan pembungkus baca-saja NumberFormatInfo .

ToString()

Mengembalikan string yang mewakili objek saat ini.

(Diperoleh dari Object)

Berlaku untuk

Lihat juga