NumberFormatInfo.NumberDecimalSeparator Properti

Definisi

Mendapatkan atau mengatur string yang akan digunakan sebagai pemisah desimal dalam nilai numerik.

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

Nilai Properti

String yang digunakan sebagai pemisah desimal dalam nilai numerik. Default untuk InvariantInfo adalah ".".

Pengecualian

Properti sedang diatur ke null.

Properti sedang diatur dan NumberFormatInfo objek bersifat baca-saja.

Properti sedang diatur ke string kosong.

Contoh

Contoh berikut menunjukkan efek mengubah NumberDecimalSeparator properti.

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->NumberDecimalSeparator = " ";
   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.NumberDecimalSeparator = " ";
      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.NumberDecimalSeparator = " "
      Console.WriteLine(myInt.ToString("N", nfi))

   End Sub

End Class


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

Keterangan

Properti NumberDecimalSeparator digunakan dengan string format standar "E", "F", "G", "N", dan "R" untuk menentukan simbol yang memisahkan integral dari digit pecahan. Untuk informasi selengkapnya, lihat String Format Numerik Standar.

Nilai awal properti ini berasal dari pengaturan di item Wilayah dan Bahasa di Panel Kontrol.

Berlaku untuk

Lihat juga