Welcome   |  ASP.NET   |  Web Services   |  How Do I...?   |  Class Browser  | WPF Quick Starts
  |   I want my samples in...   

How Do I...? Common Tasks QuickStart Tutorial

Go To...

How Do I...Use the CultureInfo and RegionInfo classes?



The CultureInfo and RegionInfo classes are exported from the System.Globalization namespace. CultureInfo contains a culture's DisplayName, Calendar, and various official abbreviations.

		
CultureInfo c = new CultureInfo("en-us");
Console.WriteLine ("The CultureInfo is set to: {0}", c.DisplayName);
Console.WriteLine ("The parent culture is: {0}", c.Parent.DisplayName);
Console.WriteLine ("The three letter ISO language name is: {0}", c.ThreeLetterISOLanguageName);
Console.WriteLine ("The default calendar for this culture is: {0}\n\n", c.Calendar.ToString());
C#


RegionInfo contains information for a given region including DisplayName, currency information, and official abbreviations. RegionInfo also contains a static property to retrieve the CurrentRegion.

		
RegionInfo r = new RegionInfo("us");
Console.WriteLine ("The name of this region is: {0}", r.Name);
Console.WriteLine ("The currency symbol for the region is: {0}", r.CurrencySymbol);
Console.WriteLine ("Is this region metric : {0} \n\n", r.IsMetric);
C#

Example

C# CultureRegion.exe
View Source

[This sample can be found at M:\web\users\sites\AspnetQuickStart\v2.0\QuickStart\howto\samples\Globalization\CultureRegion\
To build this sample, open the SDK command prompt and navigate to the above path. Build the sample using the build tool msbuild passing the solution file as the first parameter: msbuild mySample.sln. The compiled executable will be found in the sub directory \bin directory.]




Microsoft .NET Framework SDK QuickStart Tutorials Version 2.0
Copyright � 2005 Microsoft Corporation. All rights reserved.


Hosted by MaximumASP | Found a broken link? | Contact Us | Terms and conditions | Privacy Policy | Advertise with us
� 2000 - 2010  Mindcracker LLC. All Rights Reserved