NumberFormatInfo.NumberGroupSeparator Właściwość

Definicja

Pobiera lub ustawia ciąg, który oddziela grupy cyfr po lewej stronie wartości dziesiętnych w wartościach liczbowych.

public:
 property System::String ^ NumberGroupSeparator { System::String ^ get(); void set(System::String ^ value); };
public string NumberGroupSeparator { get; set; }
member this.NumberGroupSeparator : string with get, set
Public Property NumberGroupSeparator As String

Wartość właściwości

Ciąg oddzielający grupy cyfr po lewej stronie dziesiętnej w wartościach liczbowych. Wartość domyślna to InvariantInfo ",".

Wyjątki

Właściwość jest ustawiana na null.

Właściwość jest ustawiana, a NumberFormatInfo obiekt jest tylko do odczytu.

Przykłady

W poniższym przykładzie pokazano efekt zmiany NumberGroupSeparator właściwości.

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", ").
   Int64 myInt = 123456789;
   Console::WriteLine( myInt.ToString( "N", nfi ) );
   
   // Displays the same value with a blank as the separator.
   nfi->NumberGroupSeparator = " ";
   Console::WriteLine( myInt.ToString( "N", nfi ) );
}

/*
This code produces the following output.
123, 456, 789.00
123 456 789.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 (",").
      Int64 myInt = 123456789;
      Console.WriteLine( myInt.ToString( "N", nfi ) );

      // Displays the same value with a blank as the separator.
      nfi.NumberGroupSeparator = " ";
      Console.WriteLine( myInt.ToString( "N", nfi ) );
   }
}


/*
This code produces the following output.

123,456,789.00
123 456 789.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 Int64 = 123456789
      Console.WriteLine(myInt.ToString("N", nfi))

      ' Displays the same value with a blank as the separator.
      nfi.NumberGroupSeparator = " "
      Console.WriteLine(myInt.ToString("N", nfi))

   End Sub

End Class


'This code produces the following output.
'
'123,456,789.00
'123 456 789.00

Uwagi

Właściwość NumberGroupSeparator jest używana z ciągiem formatu standardowego "N", aby zdefiniować symbol oddzielający grupy cyfr całkowitych. Aby uzyskać więcej informacji, zobacz Standardowe ciągi formatu liczbowego.

Początkowa wartość tej właściwości pochodzi z ustawień w elemencie Region i Język w Panel sterowania.

Dotyczy

Zobacz też