jae-l
5/18/2017 - 6:43 PM

How to change and print the culture info. Also known as localization in .NET.

How to change and print the culture info. Also known as localization in .NET.

DateTime d = new DateTime(2006, 05, 27, 12, 50, 34);

Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US");
Console.WriteLine("{0:N}", 1234.56); 
Console.WriteLine("{0:D}", d);       
Console.WriteLine("The culture is: " + CultureInfo.GetCultureInfo("en-US") + "\n");

// 1,234.56
// Saturday, May 27, 2006
// The culture is: en-US

Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("bg-FR");
Console.WriteLine("{0:N}", 1234.56); 
Console.WriteLine("{0:D}", d);       
Console.WriteLine("The culture is: " + CultureInfo.GetCultureInfo("bg-FR") + "\n");

// 1 234,56
// 27 ??? 2006 ?.
// The culture is: bg-FR

Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("bg-BG");
Console.WriteLine("{0:N}", 1234.56); 
Console.WriteLine("{0:D}", d);       
Console.WriteLine("The culture is: " + CultureInfo.GetCultureInfo("bg-BG") + "\n");

// 1 234,56
// 27 ??? 2006 ?.
// The culture is: bg-BG