NumberFormatInfo クラス

定義

数値の書式設定と解析に関するカルチャ固有の情報を提供します。

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
継承
NumberFormatInfo
属性
実装

注釈

この API の詳細については、「 NumberFormatInfo の補足 API 解説」を参照してください。

Example

次の例は、対応するNumberFormatInfo オブジェクトのCultureInfo オブジェクトを取得し、取得したオブジェクトを使用して特定のカルチャの数値書式情報を照会する方法を示しています。

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

コンストラクター

名前 説明
NumberFormatInfo()

カルチャに依存しない (不変) NumberFormatInfo クラスの新しい書き込み可能なインスタンスを初期化します。

プロパティ

名前 説明
CurrencyDecimalDigits

通貨値で使用する小数点以下の桁数を取得または設定します。

CurrencyDecimalSeparator

通貨値の小数点区切り記号として使用する文字列を取得または設定します。

CurrencyGroupSeparator

通貨値で小数点の左にある数字のグループを区切る文字列を取得または設定します。

CurrencyGroupSizes

通貨値の小数部の左側にある各グループの桁数を取得または設定します。

CurrencyNegativePattern

負の通貨値の書式パターンを取得または設定します。

CurrencyPositivePattern

正の通貨値の書式パターンを取得または設定します。

CurrencySymbol

通貨記号として使用する文字列を取得または設定します。

CurrentInfo

現在のカルチャに基づいて値を書式設定する読み取り専用 NumberFormatInfo を取得します。

DigitSubstitution

グラフィカル ユーザー インターフェイスで数字の図形を表示する方法を指定する値を取得または設定します。

InvariantInfo

カルチャに依存しない (不変) NumberFormatInfo 読み取り専用オブジェクトを取得します。

IsReadOnly

この NumberFormatInfo オブジェクトが読み取り専用かどうかを示す値を取得します。

NaNSymbol

IEEE NaN (数値ではない) 値を表す文字列を取得または設定します。

NativeDigits

西 0 から 9 の西桁に相当するネイティブ数字の文字列配列を取得または設定します。

NegativeInfinitySymbol

負の無限大を表す文字列を取得または設定します。

NegativeSign

関連付けられた数値が負の値であることを示す文字列を取得または設定します。

NumberDecimalDigits

数値で使用する小数点以下の桁数を取得または設定します。

NumberDecimalSeparator

数値の小数点区切り記号として使用する文字列を取得または設定します。

NumberGroupSeparator

10 進数の左側にある数字のグループを数値で区切る文字列を取得または設定します。

NumberGroupSizes

数値の 10 進数の左側にある各グループの桁数を取得または設定します。

NumberNegativePattern

負の数値の書式パターンを取得または設定します。

PercentDecimalDigits

パーセント値で使用する小数点以下の桁数を取得または設定します。

PercentDecimalSeparator

パーセント値の小数点区切り記号として使用する文字列を取得または設定します。

PercentGroupSeparator

小数点の左にある数字のグループをパーセント値で区切る文字列を取得または設定します。

PercentGroupSizes

10 進数の左にある各グループの桁数をパーセント値で取得または設定します。

PercentNegativePattern

負のパーセント値の書式パターンを取得または設定します。

PercentPositivePattern

正のパーセント値の書式パターンを取得または設定します。

PercentSymbol

パーセント記号として使用する文字列を取得または設定します。

PerMilleSymbol

ミル単位のシンボルとして使用する文字列を取得または設定します。

PositiveInfinitySymbol

正の無限大を表す文字列を取得または設定します。

PositiveSign

関連付けられた数値が正であることを示す文字列を取得または設定します。

メソッド

名前 説明
Clone()

NumberFormatInfo オブジェクトの簡易コピーを作成します。

Equals(Object)

指定したオブジェクトが現在のオブジェクトと等しいかどうかを判断します。

(継承元 Object)
GetFormat(Type)

数値書式サービスを提供する指定した型のオブジェクトを取得します。

GetHashCode()

既定のハッシュ関数として機能します。

(継承元 Object)
GetInstance(IFormatProvider)

指定したNumberFormatInfoに関連付けられているIFormatProviderを取得します。

GetType()

現在のインスタンスの Type を取得します。

(継承元 Object)
MemberwiseClone()

現在の Objectの簡易コピーを作成します。

(継承元 Object)
ReadOnly(NumberFormatInfo)

読み取り専用の NumberFormatInfo ラッパーを返します。

ToString()

現在のオブジェクトを表す文字列を返します。

(継承元 Object)

適用対象

こちらもご覧ください