NumberFormatInfo

NumberFormatInfo


Provides numeric formatting information.


Implements:

ICloneable 
IFormatProvider 
IObject 

Public:

Types:

NameDescription
 CurrencyNegativePatterns Output patterns for negative currency values. The $ is the currency symbol, then - is the negative symbol and n is the number.  
 CurrencyPositivePatterns Output patterns for positive currency values. The $ is the currency symbol and n is the number.  
 NumberNegativePatterns Output patterns for negative numbers.  
 PercentNegativePatterns Output patterns for negative percentage values. The - is the negative symbol, # is the number and the % is the percentage symbol.  
 PercentPositivePatterns Output patterns for positive percentage values. The # is the number and the % is the percentage symbol.  

Properties:

NameDescription
 CurrencyDecimalDigits (get) Returns the default number of digits after the decimal separator.  
 CurrencyDecimalDigits (let) Sets the default number of digits to be shown after the decimal separator.  
 CurrencyDecimalSeparator (get) Returns the decimal separator used in formatting numbers into currency.  
 CurrencyDecimalSeparator (let) Sets the decimal separator used in formatting numbers into currency.  
 CurrencyGroupSeparator (get) Returns the string to be use as a group separator.  
 CurrencyGroupSeparator (let) Sets the group separator to be used when separating digits.  
 CurrencyGroupSizes (get) Returns an array of longs which represent a comma separator group size.  
 CurrencyGroupSizes (let) Sets an array of longs which represent a set of group sizes before being comma separated.  
 CurrencyNegativePattern (get) The numeric pattern to be used when formatting negative values.  
 CurrencyNegativePattern (let) Sets the numeric pattern to be used when formatting negative values.  
 CurrencyPositivePattern (get) Returns the formatting pattern to be used for positive currency values.  
 CurrencyPositivePattern (let) Sets the formatting pattern to be used for positive currency values.  
 CurrencySymbol (get) Returns the currency symbol.  
 CurrencySymbol (let) Sets the currency symbol to be used.  
 IsReadOnly (get) Returns if this instance is read-only.  
 NaNSymbol (get) Returns the string representation for Not-A-Number.  
 NaNSymbol (let) Sets the string representation for Not-A-Number.  
 NegativeInfinitySymbol (get) Returns a string representation of negative infinty.  
 NegativeInfinitySymbol (let) Sets the negative infinity representation.  
 NegativeSign (get) Returns the negative symbol for negative numbers.  
 NegativeSign (let) Sets the negative symbol to be used for negative numbers.  
 NumberDecimalDigits (get) The default number of digits to be appended after the decimal point if one is used.  
 NumberDecimalDigits (let) Sets the default number of digits to be appended after the decimal point.  
 NumberDecimalSeparator (get) Returns the character used as a decimal point.  
 NumberDecimalSeparator (let) Sets the character to be used as the decimal point.  
 NumberGroupSeparator (get) Returns the separator character for groups of numbers.  
 NumberGroupSeparator (let) Sets the separator charactor for a group of numbers.  
 NumberGroupSizes (get) Returns the current group sizes array for formatted numbers.  
 NumberGroupSizes (let) Sets the group sizes for formatted numbers.  
 NumberNegativePattern (get) Returns the pattern to be used when formatting negative numbers.  
 NumberNegativePattern (let) Sets the pattern to be used when formatting negative numbers.  
 PercentDecimalDigits (get) Returns the number of digits to be displayed after the decimal point for percent formatted numbers.  
 PercentDecimalDigits (let) Sets the number of digits after the decimal point for percent formatted numbers.  
 PercentDecimalSeparator (get) Returns the decimal symbol for percent formatted numbers.  
 PercentDecimalSeparator (let) Sets the decimal symbol for percent formatted numbers.  
 PercentGroupSeparator (get) Returns the group separator for a percent formatted number.  
 PercentGroupSeparator (let) Sets the group separator for a percent formatted number.  
 PercentGroupSizes (get) Returns the current group sizes array for percent formatted numbers.  
 PercentGroupSizes (let) Sets the group sizes for percent formatted numbers.  
 PercentNegativePattern (get) Returns the selected negative pattern used in percent number formatting.  
 PercentNegativePattern (let) Sets the negative pattern to be used in formatting negative percent numbers.  
 PercentPositivePattern (get) Returns the pattern to be used in formatting positive percent numbers.  
 PercentPositivePattern (let) Sets the pattern to be used in formatting positive percent numbers.  
 PercentSymbol (get) Returns the percent symbol used in percent formatted numbers.  
 PercentSymbol (let) Set the percent symbol used in percent formatted numbers.  
 PerMilleSymbol (get) Returns the permille representation.  
 PerMilleSymbol (let) Sets the permille representation.  
 PositiveInfinitySymbol (get) Returns a string representation of positive infinity.  
 PositiveInfinitySymbol (let) Sets the positive infinity representation.  
 PositiveSign (get) Returns the current positive symbol.  
 PositiveSign (let) Sets the positive symbol.  

Methods:

NameDescription
 Clone Returns a clone of this instance.  
 Equals Returns a boolean indicating if the value and this object instance are the same instance.  
 GetFormat Returns a format provider of the requested type.  
 GetHashCode Returns a pseudo-unique number identifying this instance.  
 ToString Returns a string representation of this object instance.  

Remarks

This table is from the Microsoft Dot NET 1.1 MSDN.
Format CharacterDescription and Associated Properties
c, C Currency format. CurrencyNegativePattern, CurrencyPositivePattern, CurrencySymbol, CurrencyGroupSizes, CurrencyGroupSeparator, CurrencyDecimalDigits, CurrencyDecimalSeparator.
d, D Decimal format.
e, E Scientific (exponential) format.
f, F Fixed-point format.
g, G General format.
n, N Number format. NumberNegativePattern, NumberGroupSizes, NumberGroupSeparator, NumberDecimalDigits, NumberDecimalSeparator.
x, X Hexadecimal format.

Examples

This example shows how to format a value as a currency using the default formatting setting and a custom setting.

Private Sub Main()
    Dim Provider As New NumberFormatInfo
    
    ' Display the value using the default currency formatting.
    Debug.Print Object.ToString(123, "c", Provider)
    
    ' Set a custom currency format.
    Provider.CurrencySymbol = "$$"
    Provider.CurrencyDecimalDigits = 4
    Provider.CurrencyPositivePattern = [$ n]
    
    ' Display the value using the custom currency formatting.
    Debug.Print Object.ToString(123, "c", Provider)
End Sub

' This code produces the following output.
'
' ¤123.00
' $$ 123.0000

See Also

Project CorLib Overview

Class NumberFormatInfo Overview

NumberFormatInfoStatic

IFormatProvider

ICloneable