NumberFormatInfo.CurrencySymbol 屬性

定義

取得或設定要做為貨幣符號的字串。Gets or sets the string to use as the currency symbol.

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

屬性值

要做為貨幣符號的字串。The string to use as the currency symbol. InvariantInfo 的預設值為 "¤"。The default for InvariantInfo is "¤".

例外狀況

正在將屬性設定為 nullThe property is being set to null.

正在設定屬性,而且 NumberFormatInfo 物件為唯讀。The property is being set and the NumberFormatInfo object is read-only.

範例

下列範例會顯示目前文化特性的貨幣符號,並使用 "C" 標準數值格式字串來格式化貨幣值。The following example displays the currency symbol for the current culture and uses the "C" standard numeric format string to format a currency value.

using System;
using System.Globalization;

public class Example
{
   public static void Main()
   {
      Decimal value = 106.25m;
      Console.WriteLine("Current Culture: {0}",
                        CultureInfo.CurrentCulture.Name);
      Console.WriteLine("Currency Symbol: {0}",
                        NumberFormatInfo.CurrentInfo.CurrencySymbol);
      Console.WriteLine("Currency Value:  {0:C2}", value);
   }
}
// The example displays the following output:
//       Current Culture: en-US
//       Currency Symbol: $
//       Currency Value:  $106.25
Imports System.Globalization
Imports System.Threading

Module Example
   Public Sub Main()
      Dim value As Decimal = 106.25d
      Console.WriteLine("Current Culture: {0}",
                        CultureInfo.CurrentCulture.Name)
      Console.WriteLine("Currency Symbol: {0}",
                        NumberFormatInfo.CurrentInfo.CurrencySymbol)
      Console.WriteLine("Currency Value:  {0:C2}", value)
   End Sub
End Module
' The example displays output like the following:
'       Current Culture: en-US
'       Currency Symbol: $
'       Currency Value:  $106.25

備註

當數值以 "C CurrencySymbol "標準數值格式字串格式化時,指派給屬性的字串會包含在結果字串中。The string assigned to the CurrencySymbol property is included in the result string when a numeric value is formatted with the "C" standard numeric format string.

適用於

另請參閱