NumberFormatInfo クラス
アセンブリ: mscorlib (mscorlib.dll 内)

<SerializableAttribute> _ <ComVisibleAttribute(True)> _ Public NotInheritable Class NumberFormatInfo Implements ICloneable, IFormatProvider
[SerializableAttribute] [ComVisibleAttribute(true)] public sealed class NumberFormatInfo : ICloneable, IFormatProvider
[SerializableAttribute] [ComVisibleAttribute(true)] public ref class NumberFormatInfo sealed : ICloneable, IFormatProvider

このクラスは、通貨、桁区切り記号、その他の数値記号などの情報を格納します。
特定のカルチャの NumberFormatInfo を作成するには、そのカルチャの CultureInfo を作成し、CultureInfo.NumberFormat プロパティを取得します。現在のスレッドのカルチャに対して NumberFormatInfo を作成するには、CurrentInfo プロパティを使用します。インバリアント カルチャの NumberFormatInfo を作成するには、読み取り専用バージョンでは InvariantInfo プロパティを使用し、書き込み可能バージョンでは NumberFormatInfo コンストラクタを使用します。ニュートラル カルチャの NumberFormatInfo は作成できません。
ユーザーは、[コントロール パネル] の [地域と言語のオプション] (オペレーティング システムによっては [地域のオプション] または [地域]) を使用して、Windows の現在のカルチャに関連付けられた値の一部をオーバーライドすることもできます。たとえば、ユーザーが別の形式で日付を表示したり、カルチャの既定の通貨以外の通貨を使用したりすることを選択する場合があります。CultureInfo.UseUserOverride プロパティが true に設定されている場合は、CultureInfo.DateTimeFormat、CultureInfo.NumberFormat、CultureInfo.TextInfo の各インスタンスのプロパティもユーザー設定から取得されます。ユーザー設定と CultureInfo に関連付けられたカルチャとの間に互換性がない場合 (たとえば、選択されたカレンダーが OptionalCalendars のいずれかでない場合)、メソッドの結果およびプロパティの値は未定義です。
数値は、NumberFormatInfo のプロパティに格納されている標準パターンまたはカスタム パターンを使用して、形式指定します。値を表示する方法を変更するには、カスタム パターンをプロパティに保存するために、NumberFormatInfo を書き込み可能にする必要があります。
各標準パターンの標準形式指定文字と、設定して標準パターンを変更できる関連付けられた NumberFormatInfo プロパティを次の表に示します。
c, C | 通貨書式。 CurrencyNegativePattern, CurrencyPositivePattern, CurrencySymbol, CurrencyGroupSizes, CurrencyGroupSeparator, CurrencyDecimalDigits, CurrencyDecimalSeparator. |
d, D | |
e, E | Scientific (指数) 形式。 |
f, F | Fixed-point 形式。 |
g, G | |
n, N | Number 形式。 NumberNegativePattern, NumberGroupSizes, NumberGroupSeparator, NumberDecimalDigits, NumberDecimalSeparator. |
r, R | |
x, X |
ニュートラル カルチャを除くインバリアント カルチャまたは特定のカルチャに対してだけ、DateTimeFormatInfo または NumberFormatInfo を作成できます。インバリアント カルチャ、特定のカルチャ、およびニュートラル カルチャの詳細については、CultureInfo クラスのトピックを参照してください。
このクラスは、NumberFormatInfo オブジェクトを複製できるようにする ICloneable インターフェイスを実装します。アプリケーションに形式指定情報を提供するために、IFormatProvider も実装します。

対応する CultureInfo の NumberFormatInfo を取得し、その NumberFormatInfo を使用してそのカルチャの数値形式指定情報を問い合わせる方法を次のコード例に示します。
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'
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'

System.Globalization.NumberFormatInfo


Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


NumberFormatInfo コンストラクタ
アセンブリ: mscorlib (mscorlib.dll 内)



Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


NumberFormatInfo プロパティ
NumberFormatInfo メソッド

名前 | 説明 | |
---|---|---|
![]() | Clone | NumberFormatInfo の簡易コピーを作成します。 |
![]() | Equals | オーバーロードされます。 2 つの Object インスタンスが等しいかどうかを判断します。 ( Object から継承されます。) |
![]() | GetFormat | 数値形式指定サービスを提供する指定した型のオブジェクトを取得します。 |
![]() | GetHashCode | 特定の型のハッシュ関数として機能します。GetHashCode は、ハッシュ アルゴリズムや、ハッシュ テーブルのようなデータ構造での使用に適しています。 ( Object から継承されます。) |
![]() | GetInstance | 指定した IFormatProvider に関連付けられている NumberFormatInfo を取得します。 |
![]() | GetType | 現在のインスタンスの Type を取得します。 ( Object から継承されます。) |
![]() | ReadOnly | 読み取り専用 NumberFormatInfo ラッパーを返します。 |
![]() | ReferenceEquals | 指定した複数の Object インスタンスが同一かどうかを判断します。 ( Object から継承されます。) |
![]() | ToString | 現在の Object を表す String を返します。 ( Object から継承されます。) |

NumberFormatInfo メンバ
カルチャに応じて、数値を形式指定および表示する方法を定義します。
NumberFormatInfo データ型で公開されるメンバを以下の表に示します。



名前 | 説明 | |
---|---|---|
![]() | Clone | NumberFormatInfo の簡易コピーを作成します。 |
![]() | Equals | オーバーロードされます。 2 つの Object インスタンスが等しいかどうかを判断します。 (Object から継承されます。) |
![]() | GetFormat | 数値形式指定サービスを提供する指定した型のオブジェクトを取得します。 |
![]() | GetHashCode | 特定の型のハッシュ関数として機能します。GetHashCode は、ハッシュ アルゴリズムや、ハッシュ テーブルのようなデータ構造での使用に適しています。 (Object から継承されます。) |
![]() | GetInstance | 指定した IFormatProvider に関連付けられている NumberFormatInfo を取得します。 |
![]() | GetType | 現在のインスタンスの Type を取得します。 (Object から継承されます。) |
![]() | ReadOnly | 読み取り専用 NumberFormatInfo ラッパーを返します。 |
![]() | ReferenceEquals | 指定した複数の Object インスタンスが同一かどうかを判断します。 (Object から継承されます。) |
![]() | ToString | 現在の Object を表す String を返します。 (Object から継承されます。) |

- NumberFormatInfoのページへのリンク