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)
Visual Basic (Declaration)
Public Sub New ( _
culture As Integer _
)
Dim culture As Integer
Dim instance As New RegionInfo(culture)
public RegionInfo (
int culture
)
public:
RegionInfo (
int culture
)
public RegionInfo (
int culture
)
public function RegionInfo (
culture : int
)
Parameters
- culture
A culture identifier.
| Exception type | Condition |
|---|
ArgumentException | culture specifies either an invariant, custom, or neutral culture. |
The culture identifier is mapped to the corresponding National Language Support (NLS) locale identifier. A list of culture identifiers is provided in the CultureInfo class topic.
The name of the new RegionInfo object is the ISO 3166 2-letter code for the region, not the 2-letter language and region codes. For example, the culture identifier for the English-United States culture, which is 0x409, yields a region name of "US", not "en-US".
The following code example compares two instances of RegionInfo that were created differently.
Imports System
Imports System.Globalization
Public Class SamplesRegionInfo
Public Shared Sub Main()
' Creates a RegionInfo using the ISO 3166 two-letter code.
Dim myRI1 As New RegionInfo("US")
' Creates a RegionInfo using a CultureInfo.LCID.
Dim myRI2 As New RegionInfo(New CultureInfo("en-US", False).LCID)
' Compares the two instances.
If myRI1.Equals(myRI2) Then
Console.WriteLine("The two RegionInfo instances are equal.")
Else
Console.WriteLine("The two RegionInfo instances are NOT equal.")
End If
End Sub 'Main
End Class 'SamplesRegionInfo
'This code produces the following output.
'
'The two RegionInfo instances are equal.
using System;
using System.Globalization;
public class SamplesRegionInfo {
public static void Main() {
// Creates a RegionInfo using the ISO 3166 two-letter code.
RegionInfo myRI1 = new RegionInfo( "US" );
// Creates a RegionInfo using a CultureInfo.LCID.
RegionInfo myRI2 = new RegionInfo( new 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.
*/
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.
*/
import System.*;
import System.Globalization.*;
public class SamplesRegionInfo
{
public static void main(String[] args)
{
// Creates a RegionInfo using the ISO 3166 two-letter code.
RegionInfo myRI1 = new RegionInfo("US");
// Creates a RegionInfo using a CultureInfo.LCID.
RegionInfo myRI2 =
new RegionInfo((new CultureInfo("en-US", false)).get_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.");
}
} //main
} //SamplesRegionInfo
/*
This code produces the following output.
The two RegionInfo instances are equal.
*/
Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.
.NET Framework
Supported in: 2.0, 1.1, 1.0
.NET Compact Framework
Supported in: 2.0, 1.0