get number format information for culture
Published: 11. October 2011 | Updated: 11. October 2011License: Microsoft Public License (MS-PL)
Categories: Globalization
Tags: C# Globalization
Import namespace
using System.Globalization;
Code
var culture = CultureInfo.GetCultureInfo("en-US"); var numberFormatInfo = NumberFormatInfo.GetInstance(culture); Console.WriteLine("Currency Decimal Digits: {0}", numberFormatInfo.CurrencyDecimalDigits); Console.WriteLine("Currency Decimal Separator: {0}", numberFormatInfo.CurrencyDecimalSeparator); Console.WriteLine("Currency Group Separator: {0}", numberFormatInfo.CurrencyGroupSeparator); Console.WriteLine("Currency Group Sizes: {0}", String.Join(",", numberFormatInfo.CurrencyGroupSizes)); Console.WriteLine("Currency Negative Pattern: {0}", numberFormatInfo.CurrencyNegativePattern); Console.WriteLine("Currency Positive Pattern: {0}", numberFormatInfo.CurrencyPositivePattern); Console.WriteLine("Currency Symbol: {0}", numberFormatInfo.CurrencySymbol); Console.WriteLine("Digit Substitution: {0}", numberFormatInfo.DigitSubstitution); Console.WriteLine("NaN Symbol: {0}", numberFormatInfo.NaNSymbol); Console.WriteLine("Native Digits: {0}", String.Join(",", numberFormatInfo.NativeDigits)); Console.WriteLine("Negative Infinity Symbol: {0}", numberFormatInfo.NegativeInfinitySymbol); Console.WriteLine("Negative Sign: {0}", numberFormatInfo.NegativeSign); Console.WriteLine("Number Decimal Digits: {0}", numberFormatInfo.NumberDecimalDigits); Console.WriteLine("Number Decimal Separator: {0}", numberFormatInfo.NumberDecimalSeparator); Console.WriteLine("Number Group Separator: {0}", numberFormatInfo.NumberGroupSeparator); Console.WriteLine("Number Group Sizes: {0}", String.Join(",", numberFormatInfo.NumberGroupSizes)); Console.WriteLine("Number Negative Pattern: {0}", numberFormatInfo.NumberNegativePattern); Console.WriteLine("Percent Decimal Digits: {0}", String.Join(",", numberFormatInfo.PercentDecimalDigits)); Console.WriteLine("Percent Decimal Separator: {0}", numberFormatInfo.PercentDecimalSeparator); Console.WriteLine("Percent Group Separator: {0}", numberFormatInfo.PercentGroupSeparator); Console.WriteLine("Percent Group Sizes: {0}", String.Join(",", numberFormatInfo.PercentGroupSizes)); Console.WriteLine("Percent Negative Pattern: {0}", numberFormatInfo.PercentNegativePattern); Console.WriteLine("Percent Positive Pattern: {0}", numberFormatInfo.PercentPositivePattern); Console.WriteLine("Percent Symbol: {0}", numberFormatInfo.PercentSymbol); Console.WriteLine("Per Mille Symbol: {0}", numberFormatInfo.PerMilleSymbol); Console.WriteLine("Positive InfinitySymbol: {0}", numberFormatInfo.PositiveInfinitySymbol); Console.WriteLine("Positive Sign: {0}", numberFormatInfo.PositiveSign);Console Output:
Currency Decimal Digits: 2
Currency Decimal Separator: .
Currency Group Separator: ,
Currency Group Sizes: 3
Currency Negative Pattern: 0
Currency Positive Pattern: 0
Currency Symbol: $
Digit Substitution: None
NaN Symbol: NaN
Native Digits: 0,1,2,3,4,5,6,7,8,9
Negative Infinity Symbol: -Infinity
Negative Sign: -
Number Decimal Digits: 2
Number Decimal Separator: .
Number Group Separator: ,
Number Group Sizes: 3
Number Negative Pattern: 1
Percent Decimal Digits: 2
Percent Decimal Separator: .
Percent Group Separator: ,
Percent Group Sizes: 3
Percent Negative Pattern: 0
Percent Positive Pattern: 0
Percent Symbol: %
Per Mille Symbol: %
Positive InfinitySymbol: Infinity
Positive Sign: +
Currency Decimal Separator: .
Currency Group Separator: ,
Currency Group Sizes: 3
Currency Negative Pattern: 0
Currency Positive Pattern: 0
Currency Symbol: $
Digit Substitution: None
NaN Symbol: NaN
Native Digits: 0,1,2,3,4,5,6,7,8,9
Negative Infinity Symbol: -Infinity
Negative Sign: -
Number Decimal Digits: 2
Number Decimal Separator: .
Number Group Separator: ,
Number Group Sizes: 3
Number Negative Pattern: 1
Percent Decimal Digits: 2
Percent Decimal Separator: .
Percent Group Separator: ,
Percent Group Sizes: 3
Percent Negative Pattern: 0
Percent Positive Pattern: 0
Percent Symbol: %
Per Mille Symbol: %
Positive InfinitySymbol: Infinity
Positive Sign: +
| Send us feedback about this snippet » |





