RegionInfo.Equals(Object) Metod

Definition

Avgör om det angivna objektet är samma instans som den aktuella RegionInfo.

public:
 override bool Equals(System::Object ^ value);
public override bool Equals(object value);
override this.Equals : obj -> bool
Public Overrides Function Equals (value As Object) As Boolean

Parametrar

value
Object

Objektet som ska jämföras med den aktuella RegionInfo.

Returer

true om parametern value är ett RegionInfo objekt och dess Name egenskap är samma som egenskapen för Name det aktuella RegionInfo objektet, falseannars .

Exempel

I följande kodexempel jämförs två instanser av RegionInfo som har skapats på olika sätt.

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.

*/
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

End Class


'This code produces the following output.
'
'The two RegionInfo instances are equal.

Kommentarer

Den här metoden åsidosätter Object.Equals.

Gäller för

Se även