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

属性值

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

注解

CurrencySymbol当使用 "C"标准数字格式字符串设置数值格式时,分配给属性的字符串将包含在结果字符串中。

适用于

另请参阅