using System;
using System.Globalization;
public class ParseInt32
{
public static void Main()
{
// Define cultures whose formatting conventions are to be used.
CultureInfo[] cultures = {CultureInfo.CreateSpecificCulture("en-US"),
CultureInfo.CreateSpecificCulture("fr-FR"),
CultureInfo.CreateSpecificCulture("es-ES") };
int positiveNumber = 9999;
int negativeNumber = -9999;
string[] specifiers = {"G", "C", "D8", "E2", "F", "N", "P", "X8"};
foreach (string specifier in specifiers)
{
foreach (CultureInfo culture in cultures)
{
// Display values with "G" format specifier.
Console.WriteLine("{0} format using {1} culture: {2, 16} {3, 16}",
specifier, culture.Name,
positiveNumber.ToString(specifier, culture),
negativeNumber.ToString(specifier, culture));
}
}
}
}
/*
G format using en-US culture: 9999 -9999
G format using fr-FR culture: 9999 -9999
G format using es-ES culture: 9999 -9999
C format using en-US culture: $9,999.00 ($9,999.00)
C format using fr-FR culture: 9ÿ999,00 ? -9ÿ999,00 ?
C format using es-ES culture: 9.999,00 ? -9.999,00 ?
D8 format using en-US culture: 00009999 -00009999
D8 format using fr-FR culture: 00009999 -00009999
D8 format using es-ES culture: 00009999 -00009999
E2 format using en-US culture: 1.00E+004 -1.00E+004
E2 format using fr-FR culture: 1,00E+004 -1,00E+004
E2 format using es-ES culture: 1,00E+004 -1,00E+004
F format using en-US culture: 9999.00 -9999.00
F format using fr-FR culture: 9999,00 -9999,00
F format using es-ES culture: 9999,00 -9999,00
N format using en-US culture: 9,999.00 -9,999.00
N format using fr-FR culture: 9ÿ999,00 -9ÿ999,00
N format using es-ES culture: 9.999,00 -9.999,00
P format using en-US culture: 999,900.00 % -999,900.00 %
P format using fr-FR culture: 999ÿ900,00 % -999ÿ900,00 %
P format using es-ES culture: 999.900,00 % -999.900,00 %
X8 format using en-US culture: 0000270F FFFFD8F1
X8 format using fr-FR culture: 0000270F FFFFD8F1
X8 format using es-ES culture: 0000270F FFFFD8F1
*/