Click to Rate and Give Feedback
TechNet
TechNet Library
Collapse All/Expand All Collapse All
This page is specific to
Microsoft Visual Studio 2010/.NET Framework 4

Other versions are also available for the following:
.NET Framework Class Library
Object..::.Equals Method (Object)

Updated: October 2010

Determines whether the specified Object is equal to the current Object.

Namespace:  System
Assembly:  mscorlib (in mscorlib.dll)
Visual Basic
Public Overridable Function Equals ( _
    obj As Object _
) As Boolean
C#
public virtual bool Equals(
    Object obj
)
Visual C++
public:
virtual bool Equals(
    Object^ obj
)
F#
abstract Equals : 
        obj:Object -> bool 
override Equals : 
        obj:Object -> bool 

Parameters

obj
Type: System..::.Object
The object to compare with the current object.

Return Value

Type: System..::.Boolean
true if the specified Object is equal to the current Object; otherwise, false.

The default implementation of Equals supports reference equality for reference types, and bitwise equality for value types. Reference equality means the object references that are compared refer to the same object. Bitwise equality means the objects that are compared have the same binary representation.

Note that a derived type might override the Equals method to implement value equality. Value equality means the compared objects have the same value even though they have different binary representations. For example, consider two Decimal objects that represent the numbers 1.10 and 1.1000. The Decimal objects do not have bitwise equality because they have different binary representations to account for the different number of trailing zeroes. However, the objects have value equality because the numbers 1.10 and 1.1000 are considered equal for comparison purposes since the trailing zeroes are insignificant.

Notes to Implementers

This method can be overridden by a derived class. For example, many of the base data types return true if both objects represent the same value; otherwise, false.

This method only compares primitives and objects. It must be overridden to compare more complex structures, such as arrays of objects.

The following statements must be true for all implementations of the Equals method. In the list, x, y, and z represent object references that are not nullNothingnullptra null reference (Nothing in Visual Basic).

  • x.Equals(x) returns true, except in cases that involve floating-point types. See IEC 60559:1989, Binary Floating-point Arithmetic for Microprocessor Systems.

  • x.Equals(y) returns the same value as y.Equals(x).

  • x.Equals(y) returns true if both x and y are NaN.

  • If (x.Equals(y) && y.Equals(z)) returns true, then x.Equals(z) returns true.

  • Successive calls to x.Equals(y) return the same value as long as the objects referenced by x and y are not modified.

  • x.Equals(nullNothingnullptra null reference (Nothing in Visual Basic)) returns false.

See GetHashCode for additional required behaviors pertaining to the Equals method.

Implementations of Equals must not throw exceptions.

You can compare the current object to another object for reference equality by calling the ReferenceEquals method. In Visual Basic, you can also use the is keyword (for example, If Me Is otherObject Then …).

For some kinds of objects, it is desirable to have Equals test for value equality instead of referential equality. Such implementations of Equals return true if the two objects have the same "value", even if they are not the same instance. The type's implementer decides what constitutes an object's "value", but it is typically some or all the data stored in the instance variables of the object. For example, the value of a String is based on the characters of the string; the Equals method of the String class returns true for any two string instances that contain exactly the same characters in the same order.

Types that implement IComparable must override Equals.

Types that override Equals must also override GetHashCode; otherwise, Hashtable might not work correctly.

If your programming language supports operator overloading and if you choose to overload the equality operator for a given type, that type must override the Equals method. Such implementations of the Equals method must return the same results as the equality operator. Following this guideline will help ensure that class library code using Equals (such as ArrayList and Hashtable) behaves in a manner that is consistent with the way the equality operator is used by application code.

The following guidelines are for implementing a value type:

  • Consider overriding Equals to gain increased performance over that provided by the default implementation of Equals on ValueType.

  • If you override Equals and the language supports operator overloading, you must overload the equality operator for your value type.

The following guidelines are for implementing a reference type:

  • Consider overriding Equals on a reference type if the semantics of the type are based on the fact that the type represents some value(s).

  • Most reference types must not overload the equality operator, even if they override Equals. However, if you are implementing a reference type that is intended to have value semantics, such as a complex number type, you must override the equality operator.

The following code example compares the current instance with another object.

Visual Basic
Imports System
Imports System.IO

Class Program
    Public Shared Sub Main(ByVal args As String())
        Dim Obj1 As New Object()
        Dim Obj2 As New Object()
        Console.WriteLine(Obj1.Equals(Obj2))
        Obj2 = Obj1
        Console.WriteLine(Obj1.Equals(Obj2))
    End Sub
End Class

'This example produces the following output:
'False
'True
C#
using System;
class Program
{
    static void Main(string[] args)
    {
        Object Obj1 = new Object();
        Object Obj2 = new Object();
        Console.WriteLine(Obj1.Equals(Obj2));
        Obj2 = Obj1;
        Console.WriteLine(Obj1.Equals(Obj2)); 
    }
}

/* This example produces the following output:
False
True
 */
Visual C++
using namespace System;

void main()
{
    Object^ Obj1 = gcnew Object;
    Object^ Obj2 = gcnew Object;
    Console::WriteLine(Obj1->Equals(Obj2));
    Obj2 = Obj1;
    Console::WriteLine(Obj1->Equals(Obj2));
};

/* This example produces the following output:

False
True
 */

The following example shows a Point class that overrides the Equals method to provide value equality and a class Point3D, which is derived from Point. Because Point 's override of Equals is the first in the inheritance chain to introduce value equality, the Equals method of the base class (which is inherited from Object and checks for referential equality) is not invoked. However, Point3D.Equals invokes Point.Equals because Point implements Equals in a manner that provides value equality.

Visual Basic
Imports System

Class Point
    Inherits Object
    Protected x, y As Integer

    Public Sub New() 
        Me.x = 0
        Me.y = 0
    End Sub 'New

    Public Sub New(ByVal X As Integer, ByVal Y As Integer) 
        Me.x = X
        Me.y = Y
    End Sub 'New

    Public Overrides Function Equals(ByVal obj As Object) As Boolean 
        'Check for null and compare run-time types.
        If obj Is Nothing OrElse Not [GetType]().Equals(obj.GetType()) Then
            Return False
        End If
        Dim p As Point = CType(obj, Point)
        Return x = p.x AndAlso y = p.y
    End Function 'Equals

    Public Overrides Function GetHashCode() As Integer 
        Return x ^ y
    End Function 'GetHashCode
End Class 'Point

Class Point3D
    Inherits Point
    Private z As Integer

    Public Sub New(ByVal X As Integer, ByVal Y As Integer, ByVal Z As Integer) 
        Me.x = X
        Me.y = Y
        Me.z = Z
    End Sub 'New

    Public Overrides Function Equals(ByVal obj As Object) As Boolean 
        Return MyBase.Equals(obj) AndAlso z = CType(obj, Point3D).z
    End Function 'Equals

    Public Overrides Function GetHashCode() As Integer 
        Return MyBase.GetHashCode() ^ z
    End Function 'GetHashCode
End Class 'Point3D

Class [MyClass]
    Public Shared Sub Main() 
        Dim point2D As New Point(5, 5)
        Dim point3Da As New Point3D(5, 5, 2)
        Dim point3Db As New Point3D(5, 5, 2)

        If Not point2D.Equals(point3Da) Then
            Console.WriteLine("point2D does not equal point3Da.")
        End If
        If Not point3Db.Equals(point2D) Then
            Console.WriteLine("Likewise, point3Db does not equal point2D.")
        End If
        If point3Da.Equals(point3Db) Then
            Console.WriteLine("However, point3Da equals point3Db.")
        End If

    End Sub 'Main 
End Class '[MyClass]
' ----------------------------------
' Output should be:
' 
' point2D does not equal point3Da.
' Likewise, point3Db does not equal point2D.
' However, point3Da equals point3Db.
C#
using System;

class Point: Object {
   protected int x, y;

   public Point() {
     this.x = 0;
     this.y = 0;
   }

   public Point(int X, int Y) {
      this.x = X;
      this.y = Y;
   }

   public override bool Equals(Object obj) {
      //Check for null and compare run-time types.
      if (obj == null || GetType() != obj.GetType()) return false;
      Point p = (Point)obj;
      return (x == p.x) && (y == p.y);
   }

   public override int GetHashCode() {
      return x ^ y;
   }
}


class Point3D: Point {
   int z;

   public Point3D(int X, int Y, int Z) {
      this.x = X;
      this.y = Y;
      this.z = Z; 
   }

   public override bool Equals(Object obj) {
      return base.Equals(obj) && z == ((Point3D)obj).z;
   }

   public override int GetHashCode() {
      return base.GetHashCode() ^ z;
   }
}

class MyClass {

  public static void Main() {
     Point point2D = new Point(5, 5);
     Point3D point3Da = new Point3D(5, 5, 2);
     Point3D point3Db = new Point3D(5, 5, 2);

     if (!point2D.Equals(point3Da)) {
        Console.WriteLine("point2D does not equal point3Da.");
     }
     if (!point3Db.Equals(point2D)) {
        Console.WriteLine("Likewise, point3Db does not equal point2D.");
     }
     if (point3Da.Equals(point3Db)) {
        Console.WriteLine("However, point3Da equals point3Db.");
     }

  } 
}
// ----------------------------------
// Output should be:
// 
// point2D does not equal point3Da.
// Likewise, point3Db does not equal point2D.
// However, point3Da equals point3Db.
Visual C++
using namespace System;
ref class Point: public Object
{
protected:
   int x;
   int y;

public:
   Point()
   {
      this->x = 0;
      this->y = 0;
   }

   Point( int X, int Y )
   {
      this->x = X;
      this->y = Y;
   }

   virtual bool Equals( Object^ obj ) override
   {

      //Check for null and compare run-time types.
      if ( obj == nullptr || GetType() != obj->GetType() )
            return false;

      Point ^ p = dynamic_cast<Point^>(obj);
      return (x == p->x) && (y == p->y);
   }

   virtual int GetHashCode() override
   {
      return x ^ y;
   }

};

ref class Point3D: public Point
{
private:
   int z;

public:
   Point3D( int X, int Y, int Z )
   {
      this->x = X;
      this->y = Y;
      this->z = Z;
   }

   virtual bool Equals( Object^ obj ) override
   {
      return Point::Equals( obj ) && z == (dynamic_cast<Point3D^>(obj))->z;
   }

   virtual int GetHashCode() override
   {
      return Point::GetHashCode() ^ z;
   }

};

The Point.Equals method checks that the obj argument is not nullNothingnullptra null reference (Nothing in Visual Basic) and that it references an instance of the same type as this object. If either of those checks fail, the method returns false.

The Equals method uses GetType to determine whether the run-time types of the two objects are identical. (Note that typeof is not used here because it returns the static type.) If the method used a check of the form obj is Point, the check would return true in cases where obj is an instance of a derived class of Point, even though obj and the current instance are not of the same runtime type. Having verified that both objects are of the same type, the method casts obj to type Point and returns the result of comparing the instance variables of the two objects.

In Point3D.Equals, the inherited Equals method is invoked before anything else is done; the inherited Equals method checks to see that obj is not nullNothingnullptra null reference (Nothing in Visual Basic), that obj is an instance of the same class as this object and that the inherited instance variables match. Only when the inherited Equals returns true does the method compare the instance variables introduced in the derived class. Specifically, the cast to Point3D is not executed unless obj has been determined to be of type Point3D or a derived class of Point3D.

In the previous example, operator == (the equality operator) is used to compare the individual instance variables. In some cases, it is appropriate to use the Equals method to compare instance variables in an Equals implementation, as shown in the following code example.

Visual Basic
Imports System

Class Rectangle
    Private a, b As Point

    Public Sub New(ByVal upLeftX As Integer, ByVal upLeftY As Integer, _
                   ByVal downRightX As Integer, ByVal downRightY As Integer) 
        Me.a = New Point(upLeftX, upLeftY)
        Me.b = New Point(downRightX, downRightY)
    End Sub 'New

    Public Overrides Function Equals(ByVal obj As [Object]) As Boolean 
        ' Performs an equality check on two rectangles (Point object pairs).
        If obj Is Nothing OrElse Not [GetType]().Equals(obj.GetType()) Then
            Return False
        End If
        Dim r As Rectangle = CType(obj, Rectangle)
        'Uses Equals to compare variables.
        Return a.Equals(r.a) AndAlso b.Equals(r.b)
    End Function 'Equals

    Public Overrides Function GetHashCode() As Integer 
        Return a.GetHashCode() ^ b.GetHashCode()
    End Function 'GetHashCode
End Class 'Rectangle

' Class Point added for clean compile

Class Point
    Private x As Integer
    Private y As Integer

    Public Sub New(ByVal X As Integer, ByVal Y As Integer) 
        Me.x = X
        Me.y = Y
    End Sub 'New

    Public Overrides Function Equals(ByVal obj As [Object]) As Boolean 
        ' Performs an equality check on two points (integer pairs).
        If obj Is Nothing OrElse Not [GetType]().Equals(obj.GetType()) Then
            Return False
        End If
        Dim p As Point = CType(obj, Point)
        Return x = p.x AndAlso y = p.y

    End Function 'Equals

    Public Overrides Function GetHashCode() As Integer 
        Return x.GetHashCode() ^ y.GetHashCode()
    End Function 'GetHashCode
End Class 'Point 


Class [MyClass]
    Public Shared Sub Main() 
        Dim r1 As New Rectangle(0, 0, 100, 200)
        Dim r2 As New Rectangle(0, 0, 100, 200)
        Dim r3 As New Rectangle(0, 0, 150, 200)

        If r1.Equals(r2) Then
            Console.WriteLine("Rectangle r1 equals rectangle r2!")
        End If
        If Not r2.Equals(r3) Then
            Console.WriteLine("But rectangle r2 does not equal rectangle r3.")
        End If
    End Sub 'Main
End Class '[MyClass]
' ------------------------------
' Output should be:
' Rectangle r1 equals rectangle r2!
' But rectangle r2 does not equal rectangle r3.
C#
using System;

class Rectangle {
   Point a, b;

   public Rectangle(int upLeftX, int upLeftY, int downRightX, int downRightY) {
      this.a = new Point(upLeftX, upLeftY);
      this.b = new Point(downRightX, downRightY);
   }

   public override bool Equals(Object obj) {
     // Performs an equality check on two rectangles (Point object pairs).
      if (obj == null || GetType() != obj.GetType()) return false;
      Rectangle r = (Rectangle)obj;
      //Uses Equals to compare variables.
      return a.Equals(r.a) && b.Equals(r.b);
   }

   public override int GetHashCode() {
      return a.GetHashCode() ^ b.GetHashCode();
   }
}

// Class Point added for clean compile
class Point {
  private int x;
  private int y;

  public Point(int X, int Y) {
     this.x = X;
     this.y = Y;
  }

  public override bool Equals (Object obj) {
     // Performs an equality check on two points (integer pairs).
     if (obj == null || GetType() != obj.GetType()) return false;
     Point p = (Point)obj;
     return (x == p.x) && (y == p.y);
  }

  public override int GetHashCode() {
     return x.GetHashCode() ^ y.GetHashCode();
  }

}

class MyClass {
   public static void Main() {

      Rectangle r1 = new Rectangle(0, 0, 100, 200);
      Rectangle r2 = new Rectangle(0, 0, 100, 200);
      Rectangle r3 = new Rectangle(0, 0, 150, 200);

      if (r1.Equals(r2)) {
         Console.WriteLine("Rectangle r1 equals rectangle r2!");
      }
      if (!r2.Equals(r3)) {
         Console.WriteLine("But rectangle r2 does not equal rectangle r3.");
      }
   }
}
// ------------------------------
// Output should be:
// Rectangle r1 equals rectangle r2!
// But rectangle r2 does not equal rectangle r3.
Visual C++
ref class Rectangle
{
private:
   Point^ a;
   Point^ b;

public:
   Rectangle( int upLeftX, int upLeftY, int downRightX, int downRightY )
   {
      this->a = gcnew Point( upLeftX,upLeftY );
      this->b = gcnew Point( downRightX,downRightY );
   }

   virtual bool Equals( Object^ obj ) override
   {

      // Performs an equality check on two rectangles (Point object pairs).
      if ( obj == nullptr || GetType() != obj->GetType() )
            return false;

      Rectangle^ r = dynamic_cast<Rectangle^>(obj);

      //Uses Equals to compare variables.
      return a->Equals( r->a ) && b->Equals( r->b );
   }

   virtual int GetHashCode() override
   {
      return a->GetHashCode() ^ b->GetHashCode();
   }

};

In some languages, such as C# and Visual Basic, operator overloading is supported. When a type overloads the equality operator, it must also override the Equals method to provide the same functionality. This is typically accomplished by writing the Equals method in terms of the overloaded equality operator, as in the following example.

Visual Basic
Public Structure Complex
    Public re, im As Double

    Public Overrides Function Equals(ByVal obj As [Object]) As Boolean 
        Return TypeOf obj Is Complex AndAlso Me = CType(obj, Complex)
    End Function 

    Public Overrides Function GetHashCode() As Integer 
        Return re.GetHashCode() ^ im.GetHashCode()
    End Function 

    Public Shared Operator = (x As Complex, y As Complex) As Boolean
       Return x.re = y.re AndAlso x.im = y.im
    End Operator 

    Public Shared Operator <> (x As Complex, y As Complex) As Boolean
       Return Not (x = y)
    End Operator  
End Structure

Class Example
   Public Shared Sub Main() 
      Dim cmplx1, cmplx2 As Complex

      cmplx1.re = 4.0
      cmplx1.im = 1.0

      cmplx2.re = 2.0
      cmplx2.im = 1.0

      If cmplx1 <> cmplx2 Then
         Console.WriteLine("The two objects are not equal.")
      End If
      If Not cmplx1.Equals(cmplx2) Then
         Console.WriteLine("The two objects are not equal.")
      End If

      cmplx2.re = 4.0

      If cmplx1.Equals(cmplx2) Then
         Console.WriteLine("The two objects are now equal!")
      End If
      If cmplx1 = cmplx2 Then
         Console.WriteLine("The two objects are now equal!")
      End If
   End Sub
End Class 
' The example displays the following output:
'       The two objects are not equal.
'       The two objects are not equal.
'       The two objects are now equal!
'       The two objects are now equal!
C#
using System;

public struct Complex {
   public double re, im;

   public override bool Equals(Object obj) {
      return obj is Complex && this == (Complex)obj;
   }

   public override int GetHashCode() {
      return re.GetHashCode() ^ im.GetHashCode();
   }

   public static bool operator ==(Complex x, Complex y) {
      return x.re == y.re && x.im == y.im;
   }

   public static bool operator !=(Complex x, Complex y) {
      return !(x == y);
   }
}

class MyClass {

  public static void Main() {
    Complex cmplx1, cmplx2;

    cmplx1.re = 4.0;
    cmplx1.im = 1.0;

    cmplx2.re = 2.0;
    cmplx2.im = 1.0;

    if (cmplx1 != cmplx2)
      Console.WriteLine("The two objects are not equal.");
    if (! cmplx1.Equals(cmplx2))
      Console.WriteLine("The two objects are not equal.");

    cmplx2.re = 4.0;

    if (cmplx1 == cmplx2) 
      Console.WriteLine("The two objects are now equal!");
    if (cmplx1.Equals(cmplx2)) 
      Console.WriteLine("The two objects are now equal!");
  }
}
// The example displays the following output:
//       The two objects are not equal.
//       The two objects are not equal.
//       The two objects are now equal!
//       The two objects are now equal!
Visual C++
using namespace System;
public value struct Complex
{
public:
   double re;
   double im;
   virtual bool Equals( Object^ obj ) override
   {
      return (dynamic_cast<Complex^>(obj) != nullptr) && (*this == *dynamic_cast<Complex^>(obj));
   }

   virtual int GetHashCode() override
   {
      return re.GetHashCode() ^ im.GetHashCode();
   }

   static bool operator==( Complex x, Complex y )
   {
      return x.re == y.re && x.im == y.im;
   }

   static bool operator!=( Complex x, Complex y )
   {
      return  !(x == y);
   }
};

int main()
{
   Complex cmplx1;
   Complex cmplx2;
   cmplx1.re = 4.0;
   cmplx1.im = 1.0;
   cmplx2.re = 2.0;
   cmplx2.im = 1.0;
   if (cmplx1 != cmplx2)
      Console::WriteLine( "The two objects are not equal." );
   if (!(cmplx1.Equals(cmplx2)))
      Console::WriteLine( "The two objects are not equal." );

   cmplx2.re = 4.0;
   if (cmplx1 == cmplx2 )
      Console::WriteLine( "The two objects are now equal!" );
   if (cmplx1.Equals(cmplx2))
      Console::WriteLine( "The two objects are now equal!" );
}
// The example displays the following output:
//       The two objects are not equal.
//       The two objects are not equal.
//       The two objects are now equal!
//       The two objects are now equal!

Because Complex is a C# struct (a value type), it cannot be derived from; therefore, the Equals method need not compare the GetType results for each object, but can instead use the is operator to check the type of the obj parameter.

.NET Framework

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

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Portable Class Library

Supported in: Portable Class Library

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

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

Date

History

Reason

October 2010

Revised the last example.

Customer feedback.

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Mistake in the below "Difference between equality methods" examples      Dave31416   |   Edit   |   Show History
Herenvardo's assertion that object.ReferenceEquals("hello", "hello")==false isn't correct. The compiler optimizes string literals so that only one string instance is created for each unique value. Therefore this comparison returns true. See the Remarks in the documentation for the String.Intern method.

Also, for the example of "hello".Equals("hello")==true, that's correct, but probably not for the reason given. I haven't looked at the IL, but I'd bet there's a reference equality check at the top of that method, so that it returns true right away if you've passed the object a reference to itself (which this statement does, because of the compiler optimization mentioned above).

The post needs to be modified so that new examples are given to demonstrate the concepts that Herenvardo was getting at.
Tags What's this?: Add a tag
Flag as ContentBug
Difference between equality methods      Herenvardo ... R Petrusha - MSFT   |   Edit   |   Show History

To answer Harish Sripala's concerns:

With the static version of Equals, you can do object.Equals(null, null), and you should get true as a result. OTOH, you cannot do null.Equals(null) because null has no members.

ReferenceEquals just tests for reference equalty. For reference types this matches the default implementation of Equals, and in fact its purpose is to allow doing the reference check when you suspect the types involved may have overloaded the Equals method. If you use one (or both) arguments of value types, you will always get false due to the way boxing works. This is quite reasonable: since those values are copied each time they are passed around (at least in theory), they should never be the same object (they may be, at most, separate objects containing identical data).

"".Equals("");
true
"hello".Equals("hello");
true
object.ReferenceEquals("hello", "hello");
false
object.ReferenceEquals("", "");
true
0.Equals(0)
true
0.Equals(0.0)
false
object.ReferenceEquals(0, 0);
false

The first two are quite simple: System.String overrides the Equals method to perform textual comparison.

The third example shows off the difference with ReferenceEquals: since this can't be overriden (is a static method), you can rest assured that the arguments are compared by reference: we have two identical strings, but they are not the same string (they are separate representations of the same text).

The fourth example can be surprising: due to some optimizations, all literals representing the empty string refer to the string.Empty object, so those are indeed the same object and thus ReferenceEquals returns true.

The next examples use numbers: comparing 0 with 0 yields the obvious result. But comparing 0 with 0.0 returns false: this is because they are different types, even if numerically the values would match (0 is int, 0.0 is double). In fact, if you used 0 == 0.0, you would get true (0 is implicitly converted to double before comparing).

And finally, the example of ReferenceEquals when applied to value types: despite we know the values are blatantly the same, the CLR boxes them separately to pass them as objects, so we have indeed separate objects (and thus different references).
Tags What's this?: Add a tag
Flag as ContentBug
BCL authors don't check GetType()      JeppeSN1   |   Edit   |   Show History

There are very many cases where the authors of the Base Class Library do not follow the pattern of checking the runtime type by calling GetType(). As a consequence, more derived types might be "Equal" to BCL types, and the inheritors (we) can do nothing to prevent that.

So don't derive your reference type from a BCL type that overrides Objects.Equals :-(

I wrote a simple code example to illustrate the problem (introduced by the authors of System.Text.Encoding, System.Globalization.CultureInfo, System.Uri, and many other non-sealed classes overriding Object.Equals): http://jeppesn.dk/DerivedEquals.cs

/JeppeSN

Tags What's this?: Add a tag
Flag as ContentBug
Object's different equality method usage      Harish Sripala   |   Edit   |   Show History
What is difference between the following three methods of equality. Also please provide examples for each of these methods.
1. public static bool Equals(object objA, object objB)
2. public bool Equals(object other)
3. public static bool ReferenceEquals(object objA, object objB)
Tags What's this?: Add a tag
Flag as ContentBug
Processing
© 2012 Microsoft. All rights reserved. Terms of Use | Trademarks | Privacy Statement
Page view tracker