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 プロパティ



英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

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

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

   

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



CultureInfo.NumberFormat プロパティのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

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

©2024 GRAS Group, Inc.RSS