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 "¤".
例外
该属性设置为 null。The 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
注解
CurrencySymbol当使用 "C"标准数字格式字符串设置数值格式时,分配给属性的字符串将包含在结果字符串中。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.