0 out of 1 rated this helpful - Rate this topic

NumberFormatInfo.CurrencySymbol Property

Updated: August 2010

Gets or sets the string to use as the currency symbol.

Namespace:  System.Globalization
Assembly:  mscorlib (in mscorlib.dll)
public string CurrencySymbol { get; set; }

Property Value

Type: System.String
The string to use as the currency symbol. The default for InvariantInfo is "¤".
Exception Condition
ArgumentNullException

The property is being set to null.

InvalidOperationException

The property is being set and the NumberFormatInfo is read-only.

The following example demonstrates the CurrencySymbol property. This example is part of a larger example provided for the NumberFormatInfo class.


// Display the culture name and currency symbol.
NumberFormatInfo nfi = ci.NumberFormat;
sb.AppendFormat("The currency symbol for '{0}' is '{1}'",
    ci.DisplayName, nfi.CurrencySymbol);
sb.AppendLine();


.NET Framework

Supported in: 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Portable Class Library

Supported in: Portable Class Library

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Date

History

Reason

August 2010

Corrected currency symbol of the invariant culture.

Customer feedback.

Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ
Show-CurrencyFormatting.ps1 - sample using PowerShell
<#
.SYNOPSIS
This script re-implements an MSDN Sample showing the
use of the NumberFormatInfo class to nicely format things
in this case, currency.
.DESCRIPTION
This script iterates through the Windows cultures and
displays those whose 2-letter ISO code is 'en' and
displays how Windows formats currency in that culture.
.NOTES
File Name : Show-CurrencyFormatting.ps1
Author : Thomas Lee - tfl@psp.co.uk
Requires : PowerShell Version 2.0
.LINK
This script posted to:
http://www.pshscripts.blogspot.com
MSDN sample posted to:
http://msdn.microsoft.com/en-us/library/system.globalization.numberformatinfo.aspx
.EXAMPLE
Psh > .\Show-CurrencyFormatting.ps1
The currency symbol for 'English (United States)' is '$'
The currency symbol for 'English (United Kingdom)' is '£'
The currency symbol for 'English (Australia)' is '$'
The currency symbol for 'English (Canada)' is '$'
The currency symbol for 'English (New Zealand)' is '$'
The currency symbol for 'English (Ireland)' is '€'
The currency symbol for 'English (South Africa)' is 'R'
The currency symbol for 'English (Jamaica)' is 'J$'
The currency symbol for 'English (Caribbean)' is '$'
The currency symbol for 'English (Belize)' is 'BZ$'
The currency symbol for 'English (Trinidad and Tobago)' is 'TT$'
The currency symbol for 'English (Zimbabwe)' is 'Z$'
The currency symbol for 'English (Republic of the Philippines)' is 'Php'
The currency symbol for 'English (Singapore)' is '$'
The currency symbol for 'English (Malaysia)' is 'RM'
The currency symbol for 'English (India)' is 'Rs.'

#>

# Loop through all the specific cultures known to the CLR.
foreach ($ci in [System.Globalization.CultureInfo]::GetCultures([System.Globalization.CultureTypes]::SpecificCultures))
{
# Only show the currency symbols for cultures that speak English.
if ($ci.TwoLetterISOLanguageName -eq "en") {
# Display the culture name and currency symbol.
$nfi = $ci.NumberFormat
"The currency symbol for '{0}' is '{1}'" -f $ci.DisplayName, $nfi.CurrencySymbol
}
}