RegionInfo Constructor (Int32)

Initializes a new instance of the RegionInfo class based on the country/region associated with the specified culture identifier.

Namespace:  System.Globalization
Assembly:  mscorlib (in mscorlib.dll)

public:
RegionInfo(
	int culture
)

Parameters

culture
Type: System::Int32

A culture identifier.

ExceptionCondition
ArgumentException

culture specifies either an invariant, custom, or neutral culture.

RegionInfo(String) is the recommended constructor for instantiating a RegionInfo object. Unlike the RegionInfo(Int32) constructor that requires a numeric culture identifier as a parameter, its parameter is a more readable culture name or country code.

The culture identifier is mapped to the corresponding National Language Support (NLS) locale identifier. Detailed culture information appears in the National Language Support (NLS) API Reference at the Go Global Developer Center.

The value of the Name property of the new RegionInfo object instantiated by calling this constructor is the ISO 3166 2-letter code for the country/region, not the combined language and country/region code. For example, if a RegionInfo object is instantiated with the culture identifier 0x0409 for the English (United States) culture, the value of the Name property is "US". In contrast, if a RegionInfo object is instantiated with the combined language and country/region code en-US for the English (United States) culture, the value of the Name property is "en-US".

The following code example compares two instances of RegionInfo that were created differently.

using namespace System;
using namespace System::Globalization;
int main()
{

   // Creates a RegionInfo using the ISO 3166 two-letter code.
   RegionInfo^ myRI1 = gcnew RegionInfo( "US" );

   // Creates a RegionInfo using a CultureInfo.LCID.
   RegionInfo^ myRI2 = gcnew RegionInfo( (gcnew CultureInfo( "en-US",false ))->LCID );

   // Compares the two instances. 
   if ( myRI1->Equals( myRI2 ) )
      Console::WriteLine( "The two RegionInfo instances are equal." );
   else
      Console::WriteLine( "The two RegionInfo instances are NOT equal." );
}

/*
This code produces the following output.

The two RegionInfo instances are equal.

*/

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft