Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

RegionInfo Constructor (String)

.NET Framework 1.1

Initializes a new instance of the RegionInfo class based on the country/region specified by name.

[Visual Basic]
Public Sub New( _
   ByVal name As String _
)
[C#]
public RegionInfo(
   string name
);
[C++]
public: RegionInfo(
   String* name
);
[JScript]
public function RegionInfo(
   name : String
);

Parameters

name
A string containing one of the two-letter codes defined in ISO 3166 for country/region.

Exceptions

Exception Type Condition
ArgumentNullException name is a null reference (Nothing in Visual Basic).
ArgumentException name is not a valid country/region name.

Remarks

The RegionInfo name is one of the two-letter codes defined in ISO 3166 for country/region.

Case is not significant; however, the Name, the TwoLetterISORegionName, and the ThreeLetterISORegionName properties return the appropriate code in uppercase.

The predefined RegionInfo names are listed in the RegionInfo class topic.

Example

[Visual Basic, C#, C++] The following code example compares two instances of RegionInfo that were created differently.

[Visual Basic] 
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.



[C#] 
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.

*/

[C++] 
#using <mscorlib.dll>
using namespace System;
using namespace System::Globalization;

int main()  {

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

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

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

}

/*
This code produces the following output.

The two RegionInfo instances are equal.

*/

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework

See Also

RegionInfo Class | RegionInfo Members | System.Globalization Namespace | RegionInfo Constructor Overload List

Show:
© 2015 Microsoft