NumberFormatInfo.PercentGroupSizes プロパティ
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
パーセント値で小数点の左にある各グループの数字の数を取得または設定します。
public:
property cli::array <int> ^ PercentGroupSizes { cli::array <int> ^ get(); void set(cli::array <int> ^ value); };
public int[] PercentGroupSizes { get; set; }
member this.PercentGroupSizes : int[] with get, set
Public Property PercentGroupSizes As Integer()
プロパティ値
- Int32[]
パーセント値で小数点の左にある各グループの数字の数。 InvariantInfo の既定値は 1 つだけの要素を持つ 1 次元配列であり、その要素は 3 に設定されます。
例外
プロパティが null
に設定されています。
プロパティが設定され、配列には 0 より小さいか、9 よりも大きいエントリが含まれています。
または
プロパティが設定され、配列には 0 に設定されているエントリ (最後のエントリ以外) が含まれています。
このプロパティが設定されていますが、NumberFormatInfo オブジェクトは読み取り専用です。
例
次の例は、プロパティを変更した場合の影響を示して PercentGroupSizes います。
using namespace System;
using namespace System::Globalization;
int main()
{
// Gets a NumberFormatInfo associated with the en-US culture.
CultureInfo^ MyCI = gcnew CultureInfo( "en-US",false );
NumberFormatInfo^ nfi = MyCI->NumberFormat;
// Displays a value with the default separator (S".").
Double myInt = 123456789012345.6789;
Console::WriteLine( myInt.ToString( "P", nfi ) );
// Displays the same value with different groupings.
array<Int32>^mySizes1 = {2,3,4};
array<Int32>^mySizes2 = {2,3,0};
nfi->PercentGroupSizes = mySizes1;
Console::WriteLine( myInt.ToString( "P", nfi ) );
nfi->PercentGroupSizes = mySizes2;
Console::WriteLine( myInt.ToString( "P", nfi ) );
}
/*
This code produces the following output.
12, 345, 678, 901, 234, 600.00 %
1234, 5678, 9012, 346, 00.00 %
123456789012, 346, 00.00 %
*/
using System;
using System.Globalization;
class NumberFormatInfoSample {
public static void Main() {
// Gets a NumberFormatInfo associated with the en-US culture.
NumberFormatInfo nfi = new CultureInfo( "en-US", false ).NumberFormat;
// Displays a value with the default separator (".").
Double myInt = 123456789012345.6789;
Console.WriteLine( myInt.ToString( "P", nfi ) );
// Displays the same value with different groupings.
int[] mySizes1 = {2,3,4};
int[] mySizes2 = {2,3,0};
nfi.PercentGroupSizes = mySizes1;
Console.WriteLine( myInt.ToString( "P", nfi ) );
nfi.PercentGroupSizes = mySizes2;
Console.WriteLine( myInt.ToString( "P", nfi ) );
}
}
/*
This code produces the following output.
12,345,678,901,234,600.00 %
1234,5678,9012,346,00.00 %
123456789012,346,00.00 %
*/
Imports System.Globalization
Class NumberFormatInfoSample
Public Shared Sub Main()
' Gets a NumberFormatInfo associated with the en-US culture.
Dim nfi As NumberFormatInfo = New CultureInfo("en-US", False).NumberFormat
' Displays a value with the default separator (".").
Dim myInt As [Double] = 123456789012345.6789
Console.WriteLine(myInt.ToString("P", nfi))
' Displays the same value with different groupings.
Dim mySizes1 As Integer() = {2, 3, 4}
Dim mySizes2 As Integer() = {2, 3, 0}
nfi.PercentGroupSizes = mySizes1
Console.WriteLine(myInt.ToString("P", nfi))
nfi.PercentGroupSizes = mySizes2
Console.WriteLine(myInt.ToString("P", nfi))
End Sub
End Class
'This code produces the following output.
'
'12,345,678,901,234,600.00 %
'1234,5678,9012,346,00.00 %
'123456789012,346,00.00 %
注釈
プロパティは、 PercentGroupSizes "P" 標準書式指定文字列と共に使用して、整数グループに出現する桁数を定義します。 詳細については、「標準の数値書式指定文字列」を参照してください。 1次元配列のすべての要素は、1 ~ 9 の整数である必要があります。 最後の要素には0を指定できます。
配列の最初の要素は、の左側の最下位の数字グループに含まれる要素の数を定義し PercentDecimalSeparator ます。 後続の各要素は、前のグループの左側にある次の重要な数字のグループを参照します。 配列の最後の要素が0でない場合、残りの数字は配列の最後の要素に基づいてグループ化されます。 最後の要素が0の場合、残りの桁はグループ化されません。
たとえば、配列に {3, 4, 5} が含まれている場合、数字は "55, 55555, 55555, 55555, 4444, 333.00%" のようにグループ化されます。 配列に {3, 4, 0} が含まれている場合、数字は "55555555555555555, 4444, 333.00%" のようにグループ化されます。