NumberFormatInfo.InvariantInfo Property

Gets the default read-only NumberFormatInfo object that is culture-independent (invariant).

Namespace:  System.Globalization
Assembly:  mscorlib (in mscorlib.dll)

public static NumberFormatInfo InvariantInfo { get; }

Property Value

Type: System.Globalization.NumberFormatInfo
The default read-only NumberFormatInfo object that is culture-independent (invariant).

This property does not change, regardless of the current culture.

The following example displays the default property values of the InvariantInfo object.


using System;
using System.Globalization;
using System.Text;

class Example
{

   public static void Demo(System.Windows.Controls.TextBlock outputBlock)
   {

      // Gets the InvariantInfo.
      NumberFormatInfo myInv = NumberFormatInfo.InvariantInfo;

      // Gets a UnicodeEncoding to display the Unicode value of symbols.
      UnicodeEncoding myUE = new UnicodeEncoding(true, false);
      byte[] myCodes;

      // Displays the default values for each of the properties.
      outputBlock.Text += String.Format("InvariantInfo:\nNote: Symbols might not display correctly,\ntherefore, Unicode values are included.") + "\n";
      outputBlock.Text += String.Format("\tCurrencyDecimalDigits\t\t{0}", myInv.CurrencyDecimalDigits) + "\n";
      outputBlock.Text += String.Format("\tCurrencyDecimalSeparator\t{0}", myInv.CurrencyDecimalSeparator) + "\n";
      outputBlock.Text += String.Format("\tCurrencyGroupSeparator\t\t{0}", myInv.CurrencyGroupSeparator) + "\n";
      outputBlock.Text += String.Format("\tCurrencyGroupSizes\t\t{0}", myInv.CurrencyGroupSizes[0]) + "\n";
      outputBlock.Text += String.Format("\tCurrencyNegativePattern\t\t{0}", myInv.CurrencyNegativePattern) + "\n";
      outputBlock.Text += String.Format("\tCurrencyPositivePattern\t\t{0}", myInv.CurrencyPositivePattern) + "\n";
      myCodes = myUE.GetBytes(myInv.CurrencySymbol);
      outputBlock.Text += String.Format("\tCurrencySymbol\t\t\t{0}\t(U+{1:x2}{2:x2})", myInv.CurrencySymbol, myCodes[0], myCodes[1]) + "\n";
      outputBlock.Text += String.Format("\tNaNSymbol\t\t\t{0}", myInv.NaNSymbol) + "\n";
      outputBlock.Text += String.Format("\tNegativeInfinitySymbol\t\t{0}", myInv.NegativeInfinitySymbol) + "\n";
      outputBlock.Text += String.Format("\tNegativeSign\t\t\t{0}", myInv.NegativeSign) + "\n";
      outputBlock.Text += String.Format("\tNumberDecimalDigits\t\t{0}", myInv.NumberDecimalDigits) + "\n";
      outputBlock.Text += String.Format("\tNumberDecimalSeparator\t\t{0}", myInv.NumberDecimalSeparator) + "\n";
      outputBlock.Text += String.Format("\tNumberGroupSeparator\t\t{0}", myInv.NumberGroupSeparator) + "\n";
      outputBlock.Text += String.Format("\tNumberGroupSizes\t\t{0}", myInv.NumberGroupSizes[0]) + "\n";
      outputBlock.Text += String.Format("\tNumberNegativePattern\t\t{0}", myInv.NumberNegativePattern) + "\n";
      outputBlock.Text += String.Format("\tPercentDecimalDigits\t\t{0}", myInv.PercentDecimalDigits) + "\n";
      outputBlock.Text += String.Format("\tPercentDecimalSeparator\t\t{0}", myInv.PercentDecimalSeparator) + "\n";
      outputBlock.Text += String.Format("\tPercentGroupSeparator\t\t{0}", myInv.PercentGroupSeparator) + "\n";
      outputBlock.Text += String.Format("\tPercentGroupSizes\t\t{0}", myInv.PercentGroupSizes[0]) + "\n";
      outputBlock.Text += String.Format("\tPercentNegativePattern\t\t{0}", myInv.PercentNegativePattern) + "\n";
      outputBlock.Text += String.Format("\tPercentPositivePattern\t\t{0}", myInv.PercentPositivePattern) + "\n";
      myCodes = myUE.GetBytes(myInv.PercentSymbol);
      outputBlock.Text += String.Format("\tPercentSymbol\t\t\t{0}\t(U+{1:x2}{2:x2})", myInv.PercentSymbol, myCodes[0], myCodes[1]) + "\n";
      myCodes = myUE.GetBytes(myInv.PerMilleSymbol);
      outputBlock.Text += String.Format("\tPerMilleSymbol\t\t\t{0}\t(U+{1:x2}{2:x2})", myInv.PerMilleSymbol, myCodes[0], myCodes[1]) + "\n";
      outputBlock.Text += String.Format("\tPositiveInfinitySymbol\t\t{0}", myInv.PositiveInfinitySymbol) + "\n";
      outputBlock.Text += String.Format("\tPositiveSign\t\t\t{0}", myInv.PositiveSign) + "\n";

   }
}


/*

This code produces the following output.

InvariantInfo:
Note: Symbols might not display correctly,
therefore, Unicode values are included.
        CurrencyDecimalDigits           2
        CurrencyDecimalSeparator        .
        CurrencyGroupSeparator          ,
        CurrencyGroupSizes              3
        CurrencyNegativePattern         0
        CurrencyPositivePattern         0
        CurrencySymbol                         (U+00a4)
        NaNSymbol                       NaN
        NegativeInfinitySymbol          -Infinity
        NegativeSign                    -
        NumberDecimalDigits             2
        NumberDecimalSeparator          .
        NumberGroupSeparator            ,
        NumberGroupSizes                3
        NumberNegativePattern           1
        PercentDecimalDigits            2
        PercentDecimalSeparator         .
        PercentGroupSeparator           ,
        PercentGroupSizes               3
        PercentNegativePattern          0
        PercentPositivePattern          0
        PercentSymbol                   %       (U+0025)
        PerMilleSymbol                  %       (U+2030)
        PositiveInfinitySymbol          Infinity
        PositiveSign                    +

*/



Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

XNA Framework

Supported in: Xbox 360, Windows Phone OS 7.0

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

Community Additions

ADD
Show: