Defining the culture for an application domain
With .NET 4.5, we have in our hands a way of specifying the default culture for all of our application threads in a quick and efficient way.
How to do it...
We will now define the default culture for our application domain as follows:
- Create a new Visual Studio project of type Console Application named
caCultureAppDomain
. - Open the Program.cs file and add the
using
clause for globalization:using System.Globalization;
- Next, add the following methods:
static void DefineAppDomainCulture() { String CultureString = "en-US"; DisplayCulture(); CultureInfo.DefaultThreadCurrentCulture = CultureInfo.CreateSpecificCulture(CultureString); CultureInfo.DefaultThreadCurrentUICulture = CultureInfo.CreateSpecificCulture(CultureString); ...
Get Microsoft .NET Framework 4.5 Quickstart Cookbook now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.