CSharp - Write program to Display Localized Output

Requirements

Number formatting works according to the Windows language setting.

You will display numbers in two different language styles, Czech and American.

Hint

Add import for System.Globalization namespace.

Use CultureInfo to get the localized settings

Demo

using System;
using System.Globalization;

class Program//ww w . j a  va 2s . c o  m
{
    static void Main(string[] args)
    {
        // Whole and decimal number 
        int wholeNumber = 1234567;
        double decimalNumber = 1234567.89;

        // Localization objects 
        CultureInfo czech = new CultureInfo("cs-CZ");
        CultureInfo american = new CultureInfo("en-US");

        // Localized output 
        Console.WriteLine("Whole number - Czech: " + wholeNumber.
        ToString("N0", czech));
        Console.WriteLine("Whole number - American: " + wholeNumber.
        ToString("N0", american));

        Console.WriteLine("Decimal number - Czech: " + decimalNumber.
        ToString("N2", czech));
        Console.WriteLine("Decimal number - American: " + decimalNumber.
        ToString("N2", american));
    }
}

Result