CultureInfo.NumberFormat プロパティとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > CultureInfo.NumberFormat プロパティの意味・解説 

CultureInfo.NumberFormat プロパティ

数値、通貨、および割合を表示するカルチャに対応する書式を定義する NumberFormatInfo を取得または設定します。

名前空間: System.Globalization
アセンブリ: mscorlib (mscorlib.dll 内)
構文構文

Public Overridable Property
 NumberFormat As NumberFormatInfo
Dim instance As CultureInfo
Dim value As NumberFormatInfo

value = instance.NumberFormat

instance.NumberFormat = value
public virtual NumberFormatInfo NumberFormat { get;
 set; }
public:
virtual property NumberFormatInfo^ NumberFormat {
    NumberFormatInfo^ get ();
    void set (NumberFormatInfo^ value);
}
/** @property */
public NumberFormatInfo get_NumberFormat ()

/** @property */
public void set_NumberFormat (NumberFormatInfo
 value)
public function get NumberFormat
 () : NumberFormatInfo

public function set NumberFormat
 (value : NumberFormatInfo)

プロパティ値
数値、通貨、および割合を表示するカルチャに対応する書式を定義する NumberFormatInfo。

例外例外
例外の種類条件

ArgumentNullException

プロパティが null 参照 (Visual Basic では Nothing) に設定されています。

NotSupportedException

CultureInfo は、ニュートラル カルチャ用です。

InvalidOperationException

NumberFormat プロパティまたは NumberFormatInfo の任意のプロパティが設定されます。CultureInfo は読み取り専用です。

解説解説

ニュートラル カルチャを除くインバリアント カルチャまたは特定のカルチャに対してだけ、NumberFormatInfo を作成できます。

カルチャは、通常、インバリアント カルチャ、ニュートラル カルチャ、および特定カルチャの 3 つのセットにグループ化されます。

インバリアント カルチャは、カルチャ固有の設定ではありません。空の文字列 ("") を使用した名前で、またはカルチャ識別子 0x007F を使用することによって、インバリアント カルチャを指定できます。InvariantCulture は、インバリアント カルチャのインスタンスを取得します。この設定は、英語と関連付けられていますが、国や地域には関連付けられていません。これは、カルチャを必要とする Globalization 名前空間のほとんどのメソッドで使用できます。

ニュートラル カルチャは、国や地域ではなく、言語に関連付けられているカルチャです。特定のカルチャは、1 つの言語、および 1 つの国または地域に関連付けられたカルチャです。たとえば、"fr" はニュートラル カルチャであり、"fr-FR" は特定のカルチャです。"zh-CHS" (簡体字"zh-CHT"中国語) および "zh-CHT" (繁体字中国語) はニュートラル カルチャです。

オーバーライド

ユーザーは、[コントロール パネル] の [地域と言語のオプション] (オペレーティング システムによっては [地域のオプション] または [地域]) を使用して、Windows の現在のカルチャに関連付けられた値の一部をオーバーライドすることもできます。たとえば、ユーザーが別の形式で日付を表示したり、カルチャの既定の通貨以外の通貨を使用したりすることを選択する場合があります。

UseUserOverride が true であり、指定されたカルチャが Windows の現在のカルチャと一致する場合、CultureInfo はこれらのオーバーライド値を使用します。オーバーライド値には、DateTimeFormat プロパティによって返される DateTimeFormatInfo インスタンスのプロパティ、および NumberFormat プロパティによって返される NumberFormatInfo インスタンスのプロパティのユーザー設定値が含まれます。ユーザー設定と CultureInfo に関連付けられたカルチャとの間に互換性がない場合 (たとえば、選択されたカレンダーが OptionalCalendars のいずれかでない場合)、メソッドの結果およびプロパティの値は未定義です。

DateTimeFormat プロパティおよび NumberFormat プロパティの値は、プロパティにアクセスするまで計算されません。アプリケーションの実行中に、[コントロール パネル] を使用して現在のカルチャを新しいカルチャに変更してから、DateTimeFormat プロパティまたは NumberFormat プロパティにアクセスすると、アプリケーションは元のカルチャのオーバーライド値ではなく、新しいカルチャの既定値を取得します。元のカルチャのオーバーライド値を保持するには、現在のカルチャを変更する前に、DateTimeFormat プロパティおよび NumberFormat プロパティにアクセスします。

使用例使用例

CultureInfo.Clone が CultureInfo に関連付けられている DateTimeFormatInfo インスタンスと NumberFormatInfo インスタンスのクローンも作成するコードの例を次に示します。

Imports System
Imports System.Globalization


Public Class SamplesCultureInfo
   
   Public Shared Sub Main()
      
      ' Creates and initializes a CultureInfo.
      Dim myCI As New CultureInfo("en-US",
 False)
      
      ' Clones myCI and modifies the DTFI and NFI instances associated
 with the clone.
      Dim myCIclone As CultureInfo = CType(myCI.Clone(),
 CultureInfo)
      myCIclone.DateTimeFormat.AMDesignator = "a.m."
      myCIclone.DateTimeFormat.DateSeparator = "-"
      myCIclone.NumberFormat.CurrencySymbol = "USD"
      myCIclone.NumberFormat.NumberDecimalDigits = 4
      
      ' Displays the properties of the DTFI and NFI instances associated
 with the original and with the clone. 
      Console.WriteLine("DTFI/NFI PROPERTY" + ControlChars.Tab
 + "ORIGINAL" + ControlChars.Tab + "MODIFIED
 CLONE")
      Console.WriteLine("DTFI.AMDesignator" + ControlChars.Tab
 + "{0}" + ControlChars.Tab + ControlChars.Tab +
 "{1}", myCI.DateTimeFormat.AMDesignator, myCIclone.DateTimeFormat.AMDesignator)
      Console.WriteLine("DTFI.DateSeparator" + ControlChars.Tab
 + "{0}" + ControlChars.Tab + ControlChars.Tab +
 "{1}", myCI.DateTimeFormat.DateSeparator, myCIclone.DateTimeFormat.DateSeparator)
      Console.WriteLine("NFI.CurrencySymbol" + ControlChars.Tab
 + "{0}" + ControlChars.Tab + ControlChars.Tab +
 "{1}", myCI.NumberFormat.CurrencySymbol, myCIclone.NumberFormat.CurrencySymbol)
      Console.WriteLine("NFI.NumberDecimalDigits"
 + ControlChars.Tab + "{0}" + ControlChars.Tab +
 ControlChars.Tab + "{1}", myCI.NumberFormat.NumberDecimalDigits, myCIclone.NumberFormat.NumberDecimalDigits)

   End Sub 'Main 

End Class 'SamplesCultureInfo


' This code produces the following output.
'
' DTFI/NFI PROPERTY       ORIGINAL        MODIFIED CLONE
' DTFI.AMDesignator       AM              a.m.
' DTFI.DateSeparator      /               -
' NFI.CurrencySymbol      $               USD
' NFI.NumberDecimalDigits 2               4
using System;
using System.Globalization;


public class SamplesCultureInfo  {

   public static void Main()
  {

      // Creates and initializes a CultureInfo.
      CultureInfo myCI = new CultureInfo("en-US", false);

      // Clones myCI and modifies the DTFI and NFI instances associated
 with the clone.
      CultureInfo myCIclone = (CultureInfo) myCI.Clone();
      myCIclone.DateTimeFormat.AMDesignator = "a.m.";
      myCIclone.DateTimeFormat.DateSeparator = "-";
      myCIclone.NumberFormat.CurrencySymbol = "USD";
      myCIclone.NumberFormat.NumberDecimalDigits = 4;

      // Displays the properties of the DTFI and NFI instances associated
 with the original and with the clone. 
      Console.WriteLine( "DTFI/NFI PROPERTY\tORIGINAL\tMODIFIED CLONE"
 );
      Console.WriteLine( "DTFI.AMDesignator\t{0}\t\t{1}", myCI.DateTimeFormat.AMDesignator,
 myCIclone.DateTimeFormat.AMDesignator );
      Console.WriteLine( "DTFI.DateSeparator\t{0}\t\t{1}", myCI.DateTimeFormat.DateSeparator,
 myCIclone.DateTimeFormat.DateSeparator );
      Console.WriteLine( "NFI.CurrencySymbol\t{0}\t\t{1}", myCI.NumberFormat.CurrencySymbol,
 myCIclone.NumberFormat.CurrencySymbol );
      Console.WriteLine( "NFI.NumberDecimalDigits\t{0}\t\t{1}", myCI.NumberFormat.NumberDecimalDigits,
 myCIclone.NumberFormat.NumberDecimalDigits );
      
   }

}

/*
This code produces the following output.

DTFI/NFI PROPERTY       ORIGINAL        MODIFIED CLONE
DTFI.AMDesignator       AM              a.m.
DTFI.DateSeparator      /               -
NFI.CurrencySymbol      $               USD
NFI.NumberDecimalDigits 2               4

*/
using namespace System;
using namespace System::Globalization;
int main()
{
   
   // Creates and initializes a CultureInfo.
   CultureInfo^ myCI = gcnew CultureInfo( "en-US",false
 );
   
   // Clones myCI and modifies the DTFI and NFI instances associated
 with the clone.
   CultureInfo^ myCIclone = dynamic_cast<CultureInfo^>(myCI->Clone());
   myCIclone->DateTimeFormat->AMDesignator = "a.m.";
   myCIclone->DateTimeFormat->DateSeparator = "-";
   myCIclone->NumberFormat->CurrencySymbol = "USD";
   myCIclone->NumberFormat->NumberDecimalDigits = 4;
   
   // Displays the properties of the DTFI and NFI instances associated
 with the original and with the clone. 
   Console::WriteLine( "DTFI/NFI PROPERTY\tORIGINAL\tMODIFIED CLONE" );
   Console::WriteLine( "DTFI.AMDesignator\t{0}\t\t{1}", myCI->DateTimeFormat->AMDesignator,
 myCIclone->DateTimeFormat->AMDesignator );
   Console::WriteLine( "DTFI.DateSeparator\t{0}\t\t{1}", myCI->DateTimeFormat->DateSeparator,
 myCIclone->DateTimeFormat->DateSeparator );
   Console::WriteLine( "NFI.CurrencySymbol\t{0}\t\t{1}", myCI->NumberFormat->CurrencySymbol,
 myCIclone->NumberFormat->CurrencySymbol );
   Console::WriteLine( "NFI.NumberDecimalDigits\t{0}\t\t{1}", myCI->NumberFormat->NumberDecimalDigits,
 myCIclone->NumberFormat->NumberDecimalDigits );
}

/*
This code produces the following output.

DTFI/NFI PROPERTY       ORIGINAL        MODIFIED CLONE
DTFI.AMDesignator       AM              a.m.
DTFI.DateSeparator      /               -
NFI.CurrencySymbol      $               USD
NFI.NumberDecimalDigits 2               4
*/
import System.* ;
import System.Globalization.* ;

public class SamplesCultureInfo
{
    public static void main(String[]
 args)
    {
        // Creates and initializes a CultureInfo.
        CultureInfo myCI =  new CultureInfo("en-US",
 false);

        // Clones myCI and modifies the DTFI and NFI instances 
        // associated with the clone.
        CultureInfo myCIclone = ((CultureInfo)(myCI.Clone()));
        myCIclone.get_DateTimeFormat().set_AMDesignator( "a.m.");
        myCIclone.get_DateTimeFormat().set_DateSeparator ("-");
        myCIclone.get_NumberFormat().set_CurrencySymbol("USD");
        myCIclone.get_NumberFormat().set_NumberDecimalDigits(4);

        // Displays the properties of the DTFI and NFI instances associated
 
        // with the original and with the clone. 
        Console.WriteLine("DTFI/NFI PROPERTY\tORIGINAL\tMODIFIED CLONE");
        Console.WriteLine("DTFI.AMDesignator\t{0}\t\t{1}", 
            myCI.get_DateTimeFormat().get_AMDesignator(), 
            myCIclone.get_DateTimeFormat().get_AMDesignator());
        Console.WriteLine("DTFI.DateSeparator\t{0}\t\t{1}", 
            myCI.get_DateTimeFormat().get_DateSeparator(), 
            myCIclone.get_DateTimeFormat().get_DateSeparator());
        Console.WriteLine("NFI.CurrencySymbol\t{0}\t\t{1}", 
            myCI.get_NumberFormat().get_CurrencySymbol(), 
            myCIclone.get_NumberFormat().get_CurrencySymbol());
        Console.WriteLine("NFI.NumberDecimalDigits\t{0}\t\t{1}",
            System.Convert.ToString(
            myCI.get_NumberFormat().get_NumberDecimalDigits()), 
            System.Convert.ToString(
            myCIclone.get_NumberFormat().get_NumberDecimalDigits()));
    } //main
} //SamplesCultureInfo

/*
This code produces the following output.

DTFI/NFI PROPERTY       ORIGINAL        MODIFIED CLONE
DTFI.AMDesignator       AM              a.m.
DTFI.DateSeparator      /               -
NFI.CurrencySymbol      $               USD
NFI.NumberDecimalDigits 2               4
*/
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
CultureInfo クラス
CultureInfo メンバ
System.Globalization 名前空間
NumberFormatInfo
GetFormat
CultureInfo.DateTimeFormat プロパティ



英和和英テキスト翻訳

英語⇒日本語日本語⇒英語

辞書ショートカット

すべての辞書の索引

「CultureInfo.NumberFormat プロパティ」の関連用語

CultureInfo.NumberFormat プロパティのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



CultureInfo.NumberFormat プロパティのページの著作権

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2026 Microsoft.All rights reserved.

©2026 GRAS Group, Inc.RSS