This documentation is archived and is not being maintained.

RegionInfo.Equals Method

Determines whether the specified object is the same instance as the current RegionInfo.

[Visual Basic]
Overrides Public Function Equals( _
   ByVal value As Object _
) As Boolean
[C#]
public override bool Equals(
 object value
);
[C++]
public: bool Equals(
 Object* value
);
[JScript]
public override function Equals(
   value : Object
) : Boolean;

Parameters

value
The object to compare with the current RegionInfo.

Return Value

true if value is the same instance as the current RegionInfo; otherwise, false.

Remarks

This method overrides Object.Equals.

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 | Object.Equals

Show: