Sdílet prostřednictvím


NumberFormatInfo.PercentDecimalSeparator Vlastnost

Definice

Získá nebo nastaví řetězec, který se má použít jako oddělovač desetinných míst v procentech hodnot.

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

Hodnota vlastnosti

Řetězec, který se má použít jako oddělovač desetinných míst v procentech hodnot. Výchozí hodnota je InvariantInfo ".".

Výjimky

Vlastnost je nastavena na nullhodnotu .

Vlastnost je nastavena a NumberFormatInfo objekt je jen pro čtení.

Vlastnost je nastavena na prázdný řetězec.

Příklady

Následující příklad ukazuje účinek změny PercentDecimalSeparator vlastnosti.

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

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


/*
This code produces the following output.

12.34 %
12 34 %
*/
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] = 0.1234
      Console.WriteLine(myInt.ToString("P", nfi))

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

   End Sub

End Class


'This code produces the following output.
'
'12.34 %
'12 34 %

Poznámky

Vlastnost PercentDecimalSeparator se používá se standardním formátovacím řetězcem "P" k definování symbolu, který odděluje integrál od desetinných číslic. Další informace naleznete v tématu Standardní číselné formátovací řetězce.

Platí pro

Viz také