CultureInfo.NumberFormat プロパティ
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
数値、通貨、割合を表示する、カルチャに対応する書式を定義する NumberFormatInfo を取得または設定します。
public:
virtual property System::Globalization::NumberFormatInfo ^ NumberFormat { System::Globalization::NumberFormatInfo ^ get(); void set(System::Globalization::NumberFormatInfo ^ value); };
public virtual System.Globalization.NumberFormatInfo NumberFormat { get; set; }
member this.NumberFormat : System.Globalization.NumberFormatInfo with get, set
Public Overridable Property NumberFormat As NumberFormatInfo
プロパティ値
数値、通貨、および割合を表示するカルチャに対応する書式を定義する NumberFormatInfo。
例外
プロパティが null に設定されています。
NumberFormat プロパティまたは NumberFormatInfo プロパティのいずれかが設定され、CultureInfo は読み取り専用です。
例
次のコード例では、CultureInfo.Clone によって、 に関連付けられている および DateTimeFormatInfo インスタンス NumberFormatInfo も複製されます CultureInfo 。
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
*/
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
*/
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
End Class
' 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
注釈
上書き
ユーザーは、現在のカルチャに関連付けられている値の一部を、Windows の地域と言語のオプション部分を通じてオーバーライドコントロール パネル。 たとえば、ユーザーは、日付を別の形式で表示したり、カルチャに既定以外の通貨を使用したりすることができます。
が で、指定したカルチャが Windows の現在のカルチャと一致する場合、 では、プロパティによって返されるインスタンスのプロパティのユーザー設定や、 プロパティによって返されるインスタンスのプロパティなど、これらのオーバーライドが使用されます。 UseUserOverride true
CultureInfo DateTimeFormatInfo DateTimeFormat NumberFormatInfo NumberFormat ユーザー設定が に関連付けられているカルチャと互換性がない場合 (たとえば、選択したカレンダーが の 1 つではない場合)、メソッドの結果とプロパティの値は未定義になります。 CultureInfo OptionalCalendars
プロパティと プロパティ DateTimeFormat の値は、ユーザーが プロパティに NumberFormat アクセスするまで計算されません。 ユーザーが コントロール パネル を使用して、アプリケーションの実行中に現在のカルチャを新しいカルチャに変更し、 プロパティまたは プロパティにアクセスした場合、アプリケーションは新しいカルチャの既定値を取得します。 DateTimeFormat NumberFormat 元のカルチャのオーバーライドではありません。 元の現在のカルチャのオーバーライドを保持するには、現在のカルチャを変更する前に、アプリケーションが プロパティと プロパティ DateTimeFormat NumberFormat にアクセスする必要があります。