DESIGNING .NET 4
WINDOWS APPLICATIONS:
GLOBALIZATION AND

LOCALIZATION

using System.Globalization;

using System.Text;

using System.Threading;

double money = 1999.99;

// Set the current culture to American English.

Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");

// Format a double as currency using the current culture: $1,999.99

Console.WriteLine(string.Format("{0:C}", money));

// Set the current culture to French.

Thread.CurrentThread.CurrentCulture = new CultureInfo("fr-FR");

// Need to set the console encoding to display non-ASCII characters correctly.

Console.OutputEncoding = Encoding.UTF8;

// Also need to set the console font (in the console Properties dialog)

//  to a font that displays the extended character set correctly.  One

//  of the following fonts:

// Consolas

// Lucida Console

// Format a double as currency using the current culture: 1 999,99 €

Console.WriteLine(string.Format("{0:C}", money));

List<string> words = new List<string>() { "Apple", "Æble", "Act" };

Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");

Console.WriteLine("US English Sort:");

words.Sort();

foreach (string word in words)

{

Console.WriteLine(word);

}

Console.WriteLine();

Thread.CurrentThread.CurrentCulture = new CultureInfo("da-DK");

Console.WriteLine("Danish German Sort:");

words.Sort();

foreach (string word in words)

{

Console.WriteLine(word);

}