System.Globalization.NumberFormatInfo Class

public sealed class NumberFormatInfo : ICloneable, IFormatProvider

Base Types

Object
  NumberFormatInfo

This type implements ICloneable and IFormatProvider.

Assembly

mscorlib

Library

BCL

Summary

Supplies culture-specific formatting information for string representations of numeric values.

Description

NumberFormatInfo supplies symbols such as currency symbols and decimal separators.

[Note: A NumberFormatInfo instance typically contains the set of symbols for a specific language and culture. Instances of NumberFormatInfo may be created to provide customized formatting information. ]

See Also

System.Globalization Namespace

Members

NumberFormatInfo Constructors

NumberFormatInfo Constructor

NumberFormatInfo Methods

NumberFormatInfo.Clone Method
NumberFormatInfo.GetFormat Method
NumberFormatInfo.ReadOnly Method

NumberFormatInfo Properties

NumberFormatInfo.CurrencyDecimalDigits Property
NumberFormatInfo.CurrencyDecimalSeparator Property
NumberFormatInfo.CurrencyGroupSeparator Property
NumberFormatInfo.CurrencyGroupSizes Property
NumberFormatInfo.CurrencyNegativePattern Property
NumberFormatInfo.CurrencyPositivePattern Property
NumberFormatInfo.CurrencySymbol Property
NumberFormatInfo.CurrentInfo Property
NumberFormatInfo.InvariantInfo Property
NumberFormatInfo.IsReadOnly Property
NumberFormatInfo.NaNSymbol Property
NumberFormatInfo.NegativeInfinitySymbol Property
NumberFormatInfo.NegativeSign Property
NumberFormatInfo.NumberDecimalDigits Property
NumberFormatInfo.NumberDecimalSeparator Property
NumberFormatInfo.NumberGroupSeparator Property
NumberFormatInfo.NumberGroupSizes Property
NumberFormatInfo.NumberNegativePattern Property
NumberFormatInfo.PerMilleSymbol Property
NumberFormatInfo.PercentDecimalDigits Property
NumberFormatInfo.PercentDecimalSeparator Property
NumberFormatInfo.PercentGroupSeparator Property
NumberFormatInfo.PercentGroupSizes Property
NumberFormatInfo.PercentNegativePattern Property
NumberFormatInfo.PercentPositivePattern Property
NumberFormatInfo.PercentSymbol Property
NumberFormatInfo.PositiveInfinitySymbol Property
NumberFormatInfo.PositiveSign Property


NumberFormatInfo Constructor

public NumberFormatInfo();

Summary

Constructs and initializes a new instance of the NumberFormatInfo class.

Description

The new instance is not read-only, and is otherwise identical to the NumberFormatInfo instance returned by the System.Globalization.NumberFormatInfo.InvariantInfo property.

See Also

System.Globalization.NumberFormatInfo Class, System.Globalization Namespace

NumberFormatInfo.Clone Method

public object Clone();

Summary

Creates a copy of the current instance.

Return Value

A Object that is a copy of the current instance.

Description

The System.Globalization.NumberFormatInfo.Clone method returns a new instance of NumberFormatInfo with property values that are equal to the property values of the current instance. If the current instance is read-only, the clone is also read-only.

[Note: This method is implemented to support the ICloneable interface.]

See Also

System.Globalization.NumberFormatInfo Class, System.Globalization Namespace

NumberFormatInfo.GetFormat Method

public object GetFormat(Type formatType);

Summary

Returns an object of the specified type that provides formatting services.

Parameters

formatType
The Type of the formatting object to be returned.

Return Value

A formatting object of the specified Type. If no formatting object of the specified type is available, or formatType is a null reference, returns the formatting object for the current culture.

Description

[Note: This method is implemented to support the IFormatProvider interface.]

See Also

System.Globalization.NumberFormatInfo Class, System.Globalization Namespace

NumberFormatInfo.ReadOnly Method

public static NumberFormatInfo ReadOnly(NumberFormatInfo nfi);

Summary

Creates a read-only copy of the specified NumberFormatInfo instance.

Parameters

nfi
A NumberFormatInfo object to copy.

Return Value

A Object that is a copy of the current instance, and cannot be altered.

Exceptions

Exception TypeCondition
ArgumentNullExceptionnfi is a null reference.

See Also

System.Globalization.NumberFormatInfo Class, System.Globalization Namespace

NumberFormatInfo.CurrencyDecimalDigits Property

public int CurrencyDecimalDigits { get; set; }

Summary

Gets or sets the number of decimal places in currency values.

Property Value

A Int32 containing the number of decimal places in currency values.

Exceptions

Exception TypeCondition
ArgumentOutOfRangeExceptionThe value specified for a set operation is less than 0 or greater than 99.
InvalidOperationExceptionThe current instance is read-only and a set operation was attempted.

Description

The culture-invariant value for this property is 2.

See Also

System.Globalization.NumberFormatInfo Class, System.Globalization Namespace

NumberFormatInfo.CurrencyDecimalSeparator Property

public string CurrencyDecimalSeparator { get; set; }

Summary

Gets or sets the symbol used as the decimal separator in currency values.

Property Value

A String containing the decimal separator used in currency values.

Exceptions

Exception TypeCondition
ArgumentNullExceptionThe value specified for a set operation is a null reference.
InvalidOperationExceptionThe current instance is read-only and a set operation was attempted.

Description

The culture-invariant value for this property is ".".

See Also

System.Globalization.NumberFormatInfo Class, System.Globalization Namespace

NumberFormatInfo.CurrencyGroupSeparator Property

public string CurrencyGroupSeparator { get; set; }

Summary

Gets or sets the symbol used to separate groups of digits to the left of the decimal point in currency values.

Property Value

A String containing the group separator used in currency values.

Exceptions

Exception TypeCondition
ArgumentNullExceptionThe value specified for a set operation is a null reference.
InvalidOperationExceptionThe current instance is read-only and a set operation was attempted.

Description

The culture-invariant value for this property is ",".

See Also

System.Globalization.NumberFormatInfo Class, System.Globalization Namespace

NumberFormatInfo.CurrencyGroupSizes Property

public int[] CurrencyGroupSizes { get; set; }

Summary

Gets or sets the number of digits in each group to the left of the decimal point in currency values.

Property Value

A Int32 array containing elements that define the number of digits in each group in currency values.

Exceptions

Exception TypeCondition
ArgumentNullExceptionThe array specified for a set operation is a null reference.
ArgumentOutOfRangeExceptionOne of the elements in the array specified for a set operation is not between 0 and 9.
InvalidOperationExceptionThe current instance is read-only and a set operation was attempted.

Description

All elements of the array except the last are required to be between 1 and 9, inclusive. The last element can be 0.

The first element of the array defines the number of elements in the first group of digits located immediately to the left of the System.Globalization.NumberFormatInfo.CurrencyDecimalSeparator. Each subsequent element refers to the next group of digits located to the left of the previous group. If the last element of the array is not zero, any remaining digits are grouped based on the last element of the array. If the last element is zero, the remaining digits are not grouped.

The culture-invariant value for this property is an array with a single element containing the value 3.

Example

The following example demonstrates the effects of different System.Globalization.NumberFormatInfo.CurrencyGroupSizes property values.

using System;
using System.Globalization;
class Test {
    public static void Main() {
    NumberFormatInfo nfi = new NumberFormatInfo();
    
    decimal myMoney = 9999999994444333221.00m;
    nfi.CurrencyGroupSizes = new int[] {1,2,3,4,0};
    Console.WriteLine("{0}",myMoney.ToString("C",nfi));

    myMoney = 123456789123456.78m;
    nfi.CurrencyGroupSizes = new int[] {3};
    Console.WriteLine("{0}",myMoney.ToString("C",nfi));

    nfi.CurrencyGroupSizes = new int[] {3,0};
    Console.WriteLine("{0}",myMoney.ToString("C",nfi));

    }
}
   
The output is

$999999999,4444,333,22,1.00

$123,456,789,123,456.78

$123456789123,456.78

See Also

System.Globalization.NumberFormatInfo Class, System.Globalization Namespace

NumberFormatInfo.CurrencyNegativePattern Property

public int CurrencyNegativePattern { get; set; }

Summary

Gets or sets the format of negative currency values.

Property Value

A Int32 between 0 and 15 inclusive, which specifies the format of negative currency values.

Exceptions

Exception TypeCondition
ArgumentOutOfRangeExceptionThe value specified for a set operation is less than 0 or greater than 15.
InvalidOperationExceptionThe current instance is read-only and a set operation was attempted.

Description

The following table describes the valid values for this property. "$" is used as the value for System.Globalization.NumberFormatInfo.CurrencySymbol, "-" is used as the value for System.Globalization.NumberFormatInfo.NegativeSign, and 999 represents any numeric value.

ValuePattern
0($999)
1-$999
2$-999
3$999-
4(999$)
5-999$
6999-$
7999$-
8-999 $
9-$ 999
10999 $-
11$ 999-
12$ -999
13999- $
14($ 999)
15(999 $)
The culture-invariant value for this property is 0.

Example

The following example demonstrates the effects of different System.Globalization.NumberFormatInfo.CurrencyNegativePattern property values.

using System;
using System.Globalization;
class Test {
 public static void Main() {
 NumberFormatInfo nfi = new NumberFormatInfo();
 decimal myMoney = -9999999999999.00m;
 for (int i = 0; i<=15; i++) {
 nfi.CurrencyNegativePattern = i;
 Console.WriteLine("pattern # {0}: {1}",i,myMoney.ToString("C",nfi));
 }
 }
}
   
The output is

pattern # 0: ($9,999,999,999,999.00)

pattern # 1: -$9,999,999,999,999.00

pattern # 2: $-9,999,999,999,999.00

pattern # 3: $9,999,999,999,999.00-

pattern # 4: (9,999,999,999,999.00$)

pattern # 5: -9,999,999,999,999.00$

pattern # 6: 9,999,999,999,999.00-$

pattern # 7: 9,999,999,999,999.00$-

pattern # 8: -9,999,999,999,999.00 $

pattern # 9: -$ 9,999,999,999,999.00

pattern # 10: 9,999,999,999,999.00 $-

pattern # 11: $ 9,999,999,999,999.00-

pattern # 12: $ -9,999,999,999,999.00

pattern # 13: 9,999,999,999,999.00- $

pattern # 14: ($ 9,999,999,999,999.00)

pattern # 15: (9,999,999,999,999.00 $)

See Also

System.Globalization.NumberFormatInfo Class, System.Globalization Namespace

NumberFormatInfo.CurrencyPositivePattern Property

public int CurrencyPositivePattern { get; set; }

Summary

Gets or sets the format of positive currency values.

Property Value

A Int32 between 0 and 3 inclusive, containing the format of positive currency values.

Exceptions

Exception TypeCondition
ArgumentOutOfRangeExceptionThe value specified for a set operation is less than 0 or greater than 3.
InvalidOperationExceptionThe current instance is read-only and a set operation was attempted.

Description

The following table describes the valid values for this property. "$" is used as the value for System.Globalization.NumberFormatInfo.CurrencySymbol, and 999 represents any numeric value.

ValuePattern
0$999
1999$
2$ 999
3999 $
The culture-invariant value for this property is 0.

Example

The following example demonstrates the effects of different System.Globalization.NumberFormatInfo.CurrencyPositivePattern property values.

using System;
using System.Globalization;
class Test {
 public static void Main() {
 NumberFormatInfo nfi = new NumberFormatInfo();
 decimal myMoney = 9999999999999.00m;
 for (int i = 0; i<=3; i++) {
 nfi.CurrencyPositivePattern = i;
 Console.WriteLine("pattern # {0}: {1}",i,myMoney.ToString("C",nfi));
 }
 }
}
   
The output is

pattern # 0: $9,999,999,999,999.00

pattern # 1: 9,999,999,999,999.00$

pattern # 2: $ 9,999,999,999,999.00

pattern # 3: 9,999,999,999,999.00 $

See Also

System.Globalization.NumberFormatInfo Class, System.Globalization Namespace

NumberFormatInfo.CurrencySymbol Property

public string CurrencySymbol { get; set; }

Summary

Gets or sets the currency symbol.

Property Value

A String containing the currency symbol.

Exceptions

Exception TypeCondition
ArgumentNullExceptionThe value specified for a set operation is a null reference.
InvalidOperationExceptionThe current instance is read-only and a set operation was attempted.

Description

The culture-invariant value for this property is the Unicode currency symbol 0x00a4.

See Also

System.Globalization.NumberFormatInfo Class, System.Globalization Namespace

NumberFormatInfo.CurrentInfo Property

public static NumberFormatInfo CurrentInfo { get; }

Summary

Gets a NumberFormatInfo instance containing formatting information for the current system culture.

Property Value

A read-only NumberFormatInfo containing the settings for the current system culture.

Description

This property is read-only.

See Also

System.Globalization.NumberFormatInfo Class, System.Globalization Namespace

NumberFormatInfo.InvariantInfo Property

public static NumberFormatInfo InvariantInfo { get; }

Summary

Gets a NumberFormatInfo instance containing formatting information that is culture-independent and does not change.

Property Value

A read-only NumberFormatInfo with property values which are universally supported. The property values of the returned NumberFormatInfo are not impacted by changes to the current culture.

Description

This property is read-only.

The following table lists the property values of the NumberFormatInfo returned by this property.

PropertyDefault
CurrencyDecimalDigits 2
CurrencyDecimalSeparator "."
CurrencyGroupSeparator ","
CurrencyGroupSizes 3
CurrencyNegativePattern 0
CurrencyPositivePattern 0
CurrencySymbol 0x00a4
NaNSymbol "NaN"
NegativeInfinitySymbol "-Infinity"
NegativeSign "-"
NumberDecimalDigits 2
NumberDecimalSeparator "."
NumberGroupSeparator ","
NumberGroupSizes 3
NumberNegativePattern 1
PercentDecimalDigits 2
PercentDecimalSeparator "."
PercentGroupSeparator ","
PercentGroupSizes 3
PercentNegativePattern 0
PercentPositivePattern 0
PercentSymbol "%"
PerMilleSymbol ""
PositiveInfinitySymbol "Infinity"
PositiveSign "+"

See Also

System.Globalization.NumberFormatInfo Class, System.Globalization Namespace

NumberFormatInfo.IsReadOnly Property

public bool IsReadOnly { get; }

Summary

Gets a value indicating whether the current instance is read-only.

Property Value

true if the current instance is read-only; otherwise false .

Description

This property is read-only.

[Note: Attempting to perform an assignment to a property of a read-only NumberFormatInfo causes a InvalidOperationException.]

See Also

System.Globalization.NumberFormatInfo Class, System.Globalization Namespace

NumberFormatInfo.NaNSymbol Property

public string NaNSymbol { get; set; }

Summary

Gets or sets the symbol that represents NaN (Not-a-Number) floating-point values.

Property Value

A String containing the symbol for NaN values.

Exceptions

Exception TypeCondition
ArgumentNullExceptionThe value specified for a set operation is a null reference.
InvalidOperationExceptionThe current instance is read-only and a set operation was attempted.

Description

The culture-invariant value for this property is "NaN".

[Note: For more information on NaN values, see Double or Single.]

See Also

System.Globalization.NumberFormatInfo Class, System.Globalization Namespace

NumberFormatInfo.NegativeInfinitySymbol Property

public string NegativeInfinitySymbol { get; set; }

Summary

Gets or sets the symbol that represents negative infinity.

Property Value

A String containing the symbol for negative infinity.

Exceptions

Exception TypeCondition
ArgumentNullExceptionThe value specified for a set operation is a null reference.
InvalidOperationExceptionThe current instance is read-only and a set operation was attempted.

Description

The culture-invariant value for this property is "-Infinity".

[Note: For more information on negative infinity, see Double or Single.]

See Also

System.Globalization.NumberFormatInfo Class, System.Globalization Namespace

NumberFormatInfo.NegativeSign Property

public string NegativeSign { get; set; }

Summary

Gets or sets the symbol used to represent negative values.

Property Value

A String containing the symbol that indicates a value is negative.

Exceptions

Exception TypeCondition
ArgumentNullExceptionThe value specified for a set operation is a null reference.
InvalidOperationExceptionThe current instance is read-only and a set operation was attempted.

Description

The culture-invariant value for this property is "-".

See Also

System.Globalization.NumberFormatInfo Class, System.Globalization Namespace

NumberFormatInfo.NumberDecimalDigits Property

public int NumberDecimalDigits { get; set; }

Summary

Gets or sets the number of decimal places for numeric values.

Property Value

A Int32 containing the number of decimal places for numeric values.

Exceptions

Exception TypeCondition
ArgumentOutOfRangeExceptionThe value specified for a set operation is less than 0 or greater than 99.
InvalidOperationExceptionThe current instance is read-only and a set operation was attempted.

Description

The culture-invariant value for this property is 2.

See Also

System.Globalization.NumberFormatInfo Class, System.Globalization Namespace

NumberFormatInfo.NumberDecimalSeparator Property

public string NumberDecimalSeparator { get; set; }

Summary

Gets or sets the symbol used as the decimal separator for numeric values.

Property Value

A String containing the decimal separator.

Exceptions

Exception TypeCondition
ArgumentNullExceptionThe value specified for a set operation is a null reference.
InvalidOperationExceptionThe current instance is read-only and a set operation was attempted.

Description

The culture-invariant value for this property is ".".

See Also

System.Globalization.NumberFormatInfo Class, System.Globalization Namespace

NumberFormatInfo.NumberGroupSeparator Property

public string NumberGroupSeparator { get; set; }

Summary

Gets or sets the symbol used to separate groups of digits to the left of the decimal point for numeric values.

Property Value

A String containing the group separator.

Exceptions

Exception TypeCondition
ArgumentNullExceptionThe value specified for a set operation is a null reference.
InvalidOperationExceptionThe current instance is read-only and a set operation was attempted.

Description

The culture-invariant value for this property is ",".

See Also

System.Globalization.NumberFormatInfo Class, System.Globalization Namespace

NumberFormatInfo.NumberGroupSizes Property

public int[] NumberGroupSizes { get; set; }

Summary

Gets or sets the number of digits in each group to the left of the decimal point for numeric values.

Property Value

A Int32 array containing elements that define the number of digits in each group in numeric values.

Exceptions

Exception TypeCondition
ArgumentNullExceptionThe array specified for a set operation is a null reference.
ArgumentOutOfRangeExceptionOne of the elements in the array specified for a set operation is not between 0 and 9.
InvalidOperationExceptionThe current instance is read-only and a set operation was attempted.

Description

All elements of the array except the last are required to be between 1 and 9, inclusive. The last element can be 0.

The first element of the array defines the number of elements in the first group of digits located immediately to the left of the System.Globalization.NumberFormatInfo.NumberDecimalSeparator. Each subsequent element refers to the next group of digits located to the left of the previous group. If the last element of the array is not zero, any remaining digits are grouped based on the last element of the array. If the last element is zero, the remaining digits are not grouped.

The culture-invariant value for this property is an array with a single element containing the value 3.

Example

The following example demonstrates the effects of different System.Globalization.NumberFormatInfo.NumberGroupSizes property values.

using System;
using System.Globalization;
class Test {
 public static void Main() {
 NumberFormatInfo nfi = new NumberFormatInfo();
 
 decimal data = 9999999994444333221.00m;
 nfi.NumberGroupSizes = new int[] {1,2,3,4,0};
 Console.WriteLine("{0}",data.ToString("N",nfi));

 data = 123456789123456.78m;
 nfi.NumberGroupSizes = new int[] {3};
 Console.WriteLine("{0}",data.ToString("N",nfi));

 nfi.NumberGroupSizes = new int[] {3,0};
 Console.WriteLine("{0}",data.ToString("N",nfi));
 }
}
   
The output is

999999999,4444,333,22,1.00

123,456,789,123,456.78

123456789123,456.78

See Also

System.Globalization.NumberFormatInfo Class, System.Globalization Namespace

NumberFormatInfo.NumberNegativePattern Property

public int NumberNegativePattern { get; set; }

Summary

Gets or sets the format of negative values.

Property Value

A Int32 between 0 and 4 inclusive that specifies the format of negative values.

Exceptions

Exception TypeCondition
ArgumentOutOfRangeExceptionThe value specified for a set operation is less than 0 or greater than 4.
InvalidOperationExceptionThe current instance is read-only and a set operation was attempted.

Description

The following table describes the valid values for this property. "-" is used as the value for System.Globalization.NumberFormatInfo.NegativeSign, and 999 represents any numeric value.

ValuePattern
0(999)
1-999
2- 999
3999-
4999 -
The culture-invariant value for this property is 1.

Example

The following example demonstrates the effects of different System.Globalization.NumberFormatInfo.NumberNegativePattern property values.

using System;
using System.Globalization;
class Test {
 public static void Main() {
 NumberFormatInfo nfi = new NumberFormatInfo();
 Double data = -9999999999999.00;
 for (int i = 0; i<=4; i++) {
 nfi.NumberNegativePattern = i;
 Console.WriteLine("pattern # {0}: {1}",i,data.ToString("N",nfi));
 }
 }
}
   
The output is

pattern # 0: (9,999,999,999,999.00)

pattern # 1: -9,999,999,999,999.00

pattern # 2: - 9,999,999,999,999.00

pattern # 3: 9,999,999,999,999.00-

pattern # 4: 9,999,999,999,999.00 -

See Also

System.Globalization.NumberFormatInfo Class, System.Globalization Namespace

NumberFormatInfo.PerMilleSymbol Property

public string PerMilleSymbol { get; set; }

Summary

Gets or sets the per mille symbol.

Property Value

A String containing the per mille symbol.

Exceptions

Exception TypeCondition
ArgumentNullExceptionThe value specified for a set operation is a null reference.
InvalidOperationExceptionThe current instance is read-only and a set operation was attempted.

Description

The culture-invariant value for this property is "".

See Also

System.Globalization.NumberFormatInfo Class, System.Globalization Namespace

NumberFormatInfo.PercentDecimalDigits Property

public int PercentDecimalDigits { get; set; }

Summary

Gets or sets the number of decimal places in percent values.

Property Value

A Int32 containing the number of decimal places in percent values.

Exceptions

Exception TypeCondition
ArgumentOutOfRangeExceptionThe value specified for a set operation is less than 0 or greater than 99.
InvalidOperationExceptionThe current instance is read-only and a set operation was attempted.

Description

The culture-invariant value for this property is 2.

See Also

System.Globalization.NumberFormatInfo Class, System.Globalization Namespace

NumberFormatInfo.PercentDecimalSeparator Property

public string PercentDecimalSeparator { get; set; }

Summary

Gets or sets the symbol used as the decimal separator in percent values.

Property Value

A String containing the decimal separator used in percent values.

Exceptions

Exception TypeCondition
ArgumentNullExceptionThe value specified for a set operation is a null reference.
InvalidOperationExceptionThe current instance is read-only and a set operation was attempted.

Description

The culture-invariant value for this property is ".".

See Also

System.Globalization.NumberFormatInfo Class, System.Globalization Namespace

NumberFormatInfo.PercentGroupSeparator Property

public string PercentGroupSeparator { get; set; }

Summary

Gets or sets the symbol used to separate groups of digits to the left of the decimal point in percent values.

Property Value

A String containing the group separator symbol used in percent values.

Exceptions

Exception TypeCondition
ArgumentNullExceptionThe value specified for a set operation is a null reference.
InvalidOperationExceptionThe current instance is read-only and a set operation was attempted.

Description

The culture-invariant value for this property is ",".

See Also

System.Globalization.NumberFormatInfo Class, System.Globalization Namespace

NumberFormatInfo.PercentGroupSizes Property

public int[] PercentGroupSizes { get; set; }

Summary

Gets or sets the number of digits in each group to the left of the decimal point in percent values.

Property Value

A Int32 array containing elements that define the number of digits in each group in percent values.

Exceptions

Exception TypeCondition
ArgumentNullExceptionThe array specified for a set operation is a null reference.
ArgumentOutOfRangeExceptionOne of the elements in the array specified for a set operation is not between 0 and 9.
InvalidOperationExceptionThe current instance is read-only and a set operation was attempted.

Description

All elements of the array except the last are required to be between 1 and 9, inclusive. The last element can be 0.

The first element of the array defines the number of elements in the first group of digits located immediately to the left of the System.Globalization.NumberFormatInfo.PercentDecimalSeparator. Each subsequent element refers to the next group of digits located to the left of the previous group. If the last element of the array is not zero, any remaining digits are grouped based on the last element of the array. If the last element is zero, the remaining digits are not grouped.

The culture-invariant value for this property is an array with a single element containing the value 3.

Example

The following example demonstrates the effects of different System.Globalization.NumberFormatInfo.PercentGroupSizes property values.

using System;
using System.Globalization;
class Test {
 public static void Main() {
 NumberFormatInfo nfi = new NumberFormatInfo();
 
 decimal data = 9999999994444333221.00m;
 nfi.PercentGroupSizes = new int[] {1,2,3,4,0};
 Console.WriteLine("{0}",data.ToString("P",nfi));

 data = 123456789123456.78m;
 nfi.PercentGroupSizes = new int[] {3};
 Console.WriteLine("{0}",data.ToString("P",nfi));

 nfi.PercentGroupSizes = new int[] {3,0};
 Console.WriteLine("{0}",data.ToString("P",nfi));
 }
}
   
The output is

99999999944,4433,322,10,0.00 %

12,345,678,912,345,678.00 %

12345678912345,678.00 %

See Also

System.Globalization.NumberFormatInfo Class, System.Globalization Namespace

NumberFormatInfo.PercentNegativePattern Property

public int PercentNegativePattern { get; set; }

Summary

Gets or sets the format of negative percent values.

Property Value

A Int32 between 0 and 2 inclusive that specifies the format of negative percent values.

Exceptions

Exception TypeCondition
ArgumentOutOfRangeExceptionThe value specified for a set operation is less than 0 or greater than 2.
InvalidOperationExceptionThe current instance is read-only and a set operation was attempted.

Description

The following table describes the valid values for this property. "%" is used as the value for System.Globalization.NumberFormatInfo.PercentSymbol, "-" is used as the value for System.Globalization.NumberFormatInfo.NegativeSign, and 999 represents any numeric value.

ValuePattern
0-999 %
1-999%
2-%999
The culture-invariant value for this property is 0.

Example

The following example demonstrates the effects of different System.Globalization.NumberFormatInfo.PercentNegativePattern property values.

using System;
using System.Globalization;
class Test {
 public static void Main() {
 NumberFormatInfo nfi = new NumberFormatInfo();
 decimal data = -.9900m;
 for (int i = 0; i<=2 ; i++) {
 nfi.PercentNegativePattern = i;
 Console.WriteLine("pattern # {0}: {1}",i,data.ToString("P",nfi));
 }
 }
}
   
The output is

pattern # 0: -99.00 %

pattern # 1: -99.00%

pattern # 2: -%99.00

See Also

System.Globalization.NumberFormatInfo Class, System.Globalization Namespace

NumberFormatInfo.PercentPositivePattern Property

public int PercentPositivePattern { get; set; }

Summary

Gets or sets the format of positive percent values.

Property Value

A Int32 between 0 and 2 inclusive that specifies the format of positive percent values.

Exceptions

Exception TypeCondition
ArgumentOutOfRangeExceptionThe value specified for a set operation is less than 0 or greater than 2.
InvalidOperationExceptionThe current instance is read-only and a set operation was attempted.

Description

The following table describes the valid values for this property. "%" is used as the value for System.Globalization.NumberFormatInfo.PercentSymbol, and 999 represents a numeric value.

ValuePattern
0999 %
1999%
2%999
The culture-invariant value for this property is 0.

Example

The following example demonstrates the effects of different System.Globalization.NumberFormatInfo.PercentPositivePattern property values.

using System;
using System.Globalization;
class Test {
 public static void Main() {
 NumberFormatInfo nfi = new NumberFormatInfo();
 decimal data = .9900m;
 for (int i = 0; i<=2 ; i++) {
 nfi.PercentPositivePattern = i;
 Console.WriteLine("pattern # {0}: {1}",i,data.ToString("P",nfi));
 }
 }
}
   
The output is

pattern # 0: 99.00 %

pattern # 1: 99.00%

pattern # 2: %99.00

See Also

System.Globalization.NumberFormatInfo Class, System.Globalization Namespace

NumberFormatInfo.PercentSymbol Property

public string PercentSymbol { get; set; }

Summary

Gets or sets the symbol that represents percentage values.

Property Value

A String containing the percent symbol.

Exceptions

Exception TypeCondition
ArgumentNullExceptionThe value specified for a set operation is a null reference.
InvalidOperationExceptionThe current instance is read-only and a set operation was attempted.

Description

The culture-invariant value for this property is "%".

See Also

System.Globalization.NumberFormatInfo Class, System.Globalization Namespace

NumberFormatInfo.PositiveInfinitySymbol Property

public string PositiveInfinitySymbol { get; set; }

Summary

Gets or sets the symbol that represents positive infinity.

Property Value

A String containing the symbol for positive infinity.

Exceptions

Exception TypeCondition
ArgumentNullExceptionThe value specified for a set operation is a null reference.
InvalidOperationExceptionThe current instance is read-only and a set operation was attempted.

Description

The culture-invariant value for this property is "Infinity".

[Note: For more information on positive infinity, see Double or Single .]

See Also

System.Globalization.NumberFormatInfo Class, System.Globalization Namespace

NumberFormatInfo.PositiveSign Property

public string PositiveSign { get; set; }

Summary

Gets or sets the symbol used to represent positive values.

Property Value

A String containing the symbol that indicates the value is positive.

Exceptions

Exception TypeCondition
ArgumentNullExceptionThe value specified for a set operation is a null reference
InvalidOperationExceptionThe current instance is read-only and a set operation was attempted.

Description

The culture-invariant value for this property is "+".

See Also

System.Globalization.NumberFormatInfo Class, System.Globalization Namespace