NumberFormatInfo.CurrencySymbol 属性

定义

获取或设置用作货币符号的字符串。

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

属性值

用作货币符号的字符串。 InvariantInfo 默认为“¤”。

例外

该属性设置为 null

设置了该属性,但 NumberFormatInfo 对象为只读。

示例

以下示例显示当前区域性的货币符号,并使用“C”标准数字格式字符串设置货币值的格式。

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 属性的字符串将包含在结果 字符串中。

适用于

另请参阅